/* Kaimei AI — scrollytelling option: Same answer, different reasons (css/scrolly/two-models.css)
   Two models score one card client and both say default; as you scroll, their cards split apart and the
   reasons behind the same answer are compared row by row. js/scrolly/two-models.js adds .is-live (pinned,
   scroll-driven). Without it (no JS, reduced motion, short screens) the board shows its finished state
   and the steps read as a list. Every class is prefixed .tm- */

.tm {
  --tm-z: 0.1875;          /* where zero sits on the attribution axis (-6 to +26 points) */
  --tm-sw: 190px;          /* spine: the shared column of inputs between the two cards (fits "Credit limit · NT$20,000") */
  --tm-nw: 60px;           /* number column inside each card */
  --tm-g: 10px;
  --tm-pad: 18px;
  --tm-rh: clamp(31px, calc((100svh - 400px) / 10), 43px);
  --tm-ly: max(0px, calc((var(--tm-rh) - 31px) / 2));  /* top of a row's first line */
  --tm-bh: 12px;
  --tm-away-ink: #c2307a;
  --tm-toward-ink: #3656e0;
  --tm-hl: rgba(107, 140, 255, 0.10);
  overflow-x: clip;
}
html[data-theme="dark"] .tm {
  --tm-away-ink: #ff9fd0;
  --tm-toward-ink: #93b4ff;
  --tm-hl: rgba(107, 140, 255, 0.13);
}

/* ---------- Intro ---------- */
.tm-intro { margin-bottom: clamp(36px, 5vw, 64px); }
.tm-intro .h2 { max-width: 760px; }
.tm-intro .lead { max-width: 690px; margin-top: 20px; }

/* ---------- The board ---------- */
.tm-stage { margin: 0; width: 100%; }
.tm-board {
  position: relative; width: 100%; max-width: 800px; margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--tm-sw) minmax(0, 1fr);
  grid-template-areas: "who who who" "fh eq lh" "fc sc lc" "lg lg lg";
  font-variant-numeric: tabular-nums;
}
.tm-board > * { min-width: 0; }
.tm-who { grid-area: who; justify-self: center; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 10px; margin-bottom: 14px; font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.tm-who > span:first-child { text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-4); }
.tm-who b { font-family: var(--font-sans); font-size: 14px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }

.tm-bg { display: block; position: relative; z-index: 0; border-radius: 16px; border: 1px solid var(--line-strong); background: var(--bg-elev); box-shadow: var(--shadow-sm); }
.tm-bg-f { grid-column: 1; grid-row: 2 / 4; }
.tm-bg-l { grid-column: 3; grid-row: 2 / 4; }
.tm-bg-r { display: none; }
.tm-hd, .tm-col { position: relative; z-index: 1; }
.tm-hd-f { grid-area: fh; }
.tm-hd-l { grid-area: lh; }
.tm-col-f { grid-area: fc; }
.tm-col-s { grid-area: sc; }
.tm-col-l { grid-area: lc; }

/* "=" on the seam while the two cards still touch */
.tm-eq {
  grid-area: eq; z-index: 2; align-self: center; justify-self: center; margin-top: 18px;
  width: 30px; height: 30px; border-radius: 99px; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 15px; color: var(--ink-2);
  background: var(--bg-elev); border: 1px solid var(--line-strong); box-shadow: var(--shadow-sm);
  opacity: 0; pointer-events: none;
}

/* while the cards still touch: the answer is all there is */
.tm-why { display: none; grid-column: 1 / -1; grid-row: 3; align-self: start; justify-self: center; z-index: 2; margin-top: 22px; align-items: center; gap: 12px; font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-3); pointer-events: none; }
.tm-why::before, .tm-why::after { content: ""; width: 28px; height: 1px; background: var(--line-strong); }
.tm.is-live .tm-why { display: flex; }

/* ---------- Card header: the answer ---------- */
.tm-hd { padding: 16px var(--tm-pad) 12px; }
.tm-name { line-height: 1.3; }
.tm-name span { display: block; font-size: 12.5px; color: var(--ink-3); }
.tm-name b { display: block; font-size: 15.5px; font-weight: 600; letter-spacing: -0.015em; color: var(--ink); }
.tm-slug { margin-top: 3px; font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-verdict { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 12px; }
.tm-word { font-size: 30px; font-weight: 600; letter-spacing: -0.035em; line-height: 1; color: var(--ink); }
.tm-word.is-flip { background: var(--toward); -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 0.06em; }
.tm-p { font-family: var(--font-mono); font-size: 16px; font-weight: 500; letter-spacing: -0.02em; color: var(--ink); white-space: nowrap; }

.tm-ptrack { position: relative; height: 28px; margin-top: 8px; }
.tm-ptrack::before { content: ""; position: absolute; left: 0; right: 0; top: 19px; height: 2px; border-radius: 2px; background: var(--line-strong); }
.tm-ptrack i { position: absolute; display: block; }
.tm-plab { position: absolute; left: 0; top: 0; font-family: var(--font-mono); font-size: 11px; line-height: 1; color: var(--ink-3); }
.tm-fill { left: 0; top: 19px; height: 2px; width: 100%; border-radius: 2px; background: var(--ink-3); transform-origin: 0 50%; transform: scaleX(var(--p)); }
.tm-thr { left: 50%; top: 13px; width: 1px; height: 14px; background: var(--ink-3); }
.tm-thr span { position: absolute; left: 5px; top: -13px; font-family: var(--font-mono); font-size: 11px; font-style: normal; line-height: 1; color: var(--ink-3); }
.tm-dot, .tm-dot0 { left: calc(var(--p) * 100%); top: 20px; width: 0; height: 0; }
.tm-dot0 { left: calc(var(--p0, var(--p)) * 100%); }
.tm-dot::after, .tm-dot0::after { content: ""; position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 99px; box-sizing: border-box; background: var(--bg-elev); border: 2px solid var(--ink); }
.tm-dot0::after { left: -4px; top: -4px; width: 8px; height: 8px; border: 1.5px solid var(--ink-4); }
.tm-dot0 { opacity: 0; }
.tm-ptrack.is-flip .tm-fill { background: var(--toward); }
.tm-ptrack.is-flip .tm-dot::after { border-color: var(--tm-toward-ink); }

.tm-foot { display: grid; margin-top: 8px; font-family: var(--font-mono); font-size: 12px; line-height: 1.45; color: var(--ink-3); }
.tm-foot > span { grid-area: 1 / 1; }
.tm-foot b { font-weight: 500; color: var(--ink); }
.tm-acc > span { color: var(--ink-4); }
.tm-what { opacity: 0; }
.tm-st { display: none; }
.tm:not(.is-live) .tm-lv { display: none; }
.tm.is-live .tm-wx { display: none; }   /* the value it changes from is on the row below; the full sentence shows in the static view */

/* ---------- Rows: one input per row, aligned across both cards ---------- */
.tm-col { padding: 0 var(--tm-pad) 12px; }
.tm-axis { position: relative; height: 22px; font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); }
.tm-axis-in { position: absolute; top: 4px; bottom: 0; left: 0; right: calc(var(--tm-nw) + var(--tm-g)); }
.tm-axis-l .tm-axis-in { left: calc(var(--tm-nw) + var(--tm-g)); right: 0; }
.tm-axis-in span { position: absolute; left: calc(var(--x) * 100%); transform: translateX(-50%); }
.tm-axis-s { display: flex; justify-content: center; align-items: flex-start; gap: 14px; padding-top: 4px; }
.tm-away { color: var(--tm-away-ink); }
.tm-toward { color: var(--tm-toward-ink); }

.tm-rows { position: relative; }
.tm-col-f .tm-rows::before, .tm-col-l .tm-rows::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; right: calc(var(--tm-nw) + var(--tm-g)); pointer-events: none;
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) calc(var(--tm-z) * 100%) 0 / 1px 100% no-repeat,
    linear-gradient(var(--line), var(--line)) 50% 0 / 1px 100% no-repeat,
    linear-gradient(var(--line), var(--line)) 81.25% 0 / 1px 100% no-repeat;
}
.tm-col-l .tm-rows::before { left: calc(var(--tm-nw) + var(--tm-g)); right: 0; }

.tm-r { position: relative; height: var(--tm-rh); border-radius: 8px; }
.tm-r::before { content: ""; position: absolute; inset: 1px -8px; border-radius: 8px; background: var(--tm-hl); opacity: var(--h, 0); pointer-events: none; }
.tm-col-s .tm-r::before { inset: 1px -4px; }
.tm-plot { position: absolute; top: var(--tm-ly); height: 18px; left: 0; right: calc(var(--tm-nw) + var(--tm-g)); }
.tm-col-l .tm-plot { left: calc(var(--tm-nw) + var(--tm-g)); right: 0; }
.tm-bar, .tm-ghost { position: absolute; display: block; left: calc(var(--a) * 100%); width: calc(var(--w) * 100%); }
.tm-bar { top: calc(9px - var(--tm-bh) / 2); height: var(--tm-bh); min-width: 2px; border-radius: 3px; }
.tm-bar.tm-neg { background: var(--away); transform-origin: 100% 50%; }
.tm-bar.tm-pos { background: var(--toward); transform-origin: 0 50%; }
.tm-ghost { top: calc(9px - var(--tm-bh) / 2 - 4px); height: calc(var(--tm-bh) + 8px); min-width: 3px; border-radius: 5px; border: 1.5px dashed var(--ink-2); opacity: 0; }
.tm-ghost.tm-neg { transform-origin: 100% 50%; }
.tm-ghost.tm-pos { transform-origin: 0 50%; }
.tm-num { position: absolute; top: var(--tm-ly); right: 0; width: var(--tm-nw); height: 18px; display: grid; justify-items: end; align-items: center; font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.tm-col-l .tm-num { right: auto; left: 0; justify-items: start; }
.tm-num > span { grid-area: 1 / 1; }
.tm-num-b { opacity: 0; color: var(--ink); font-weight: 500; }

/* spine: input name and value, then the gap between the two models */
.tm-col-s { padding-inline: 4px; }
.tm-col-s .tm-r { display: grid; justify-items: center; align-content: start; padding-top: var(--tm-ly); }
.tm-lab { grid-area: 1 / 1; display: flex; align-items: baseline; justify-content: center; gap: 0 6px; height: 18px; line-height: 18px; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; }
.tm-lab b { font-weight: 500; color: var(--ink); }
.tm-lab span { color: var(--ink-3); }
.tm-lab span::before { content: "\00b7"; margin-right: 6px; color: var(--ink-4); }
.tm-lab-b { opacity: 0; }
.tm-lab-b b { color: var(--ink); }
.tm-gap { grid-area: 2 / 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 13px; }
.tm-gap i { display: block; height: 3px; width: calc(var(--d) * (var(--tm-sw) - 84px) / 2); border-radius: 3px; transform: scaleX(var(--t, 1)); }
.tm-gap i:first-child { transform-origin: 100% 50%; }
.tm-gap i:last-child { transform-origin: 0 50%; }
.tm-gap i.tm-neg { background: linear-gradient(90deg, #ff6bb5, #e86bff); }
.tm-gap i.tm-pos { background: linear-gradient(90deg, #6b8cff, #3ec8ff); }
.tm-gap em { font-style: normal; font-family: var(--font-mono); font-size: 11px; line-height: 1; color: var(--ink-2); opacity: var(--t, 1); }

.tm-legend { grid-area: lg; display: grid; justify-items: center; row-gap: 4px; margin-top: 14px; font-size: 12.5px; line-height: 1.4; color: var(--ink-3); text-align: center; }
.tm-legend > span { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 9px; }
.tm-legend i { flex: none; display: block; }
.tm-legend-u i { width: 28px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #ff6bb5, #e86bff 44%, transparent 44% 56%, #6b8cff 56%, #3ec8ff); }
.tm-legend-g i { width: 20px; height: 12px; border-radius: 4px; border: 1.5px dashed var(--ink-2); }
.tm-legend-g { opacity: 0; }
.tm-key { display: none; }

/* ---------- Steps (static list by default) ---------- */
.tm-grid { position: relative; }
.tm-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 32px; margin-top: clamp(40px, 5vw, 64px); }
.tm-steps > * { min-width: 0; }
.tm-step { border-top: 1px solid var(--line); padding-top: 18px; }
.tm-k { display: flex; gap: 10px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.tm-k span { color: var(--ink-4); }
.tm-h { margin-top: 10px; font-size: clamp(1.2rem, 1.6vw, 1.45rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; text-wrap: balance; }
.tm-tx { margin-top: 10px; color: var(--ink-2); font-size: 15.5px; line-height: 1.6; text-wrap: pretty; }

/* static: the finished state */
.tm:not(.is-live) .tm-legend-g { display: none; }
.tm:not(.is-live) .tm-foot > span { grid-area: auto; }
.tm:not(.is-live) .tm-what { opacity: 1; }
.tm:not(.is-live) .tm-st { display: inline; }
.tm:not(.is-live) .tm-foot { gap: 6px; }

/* ---------- Close ---------- */
.tm-close { margin-top: clamp(64px, 8vw, 112px); text-align: center; }
.tm-statement { max-width: 900px; margin-inline: auto; font-size: clamp(1.9rem, 4vw, 3.1rem); font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; text-wrap: balance; }
.tm-close-copy { max-width: 680px; margin: 22px auto 0; color: var(--ink-2); font-size: 1.08rem; line-height: 1.6; text-wrap: pretty; }
.tm-does { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; max-width: 1000px; margin: clamp(36px, 4vw, 52px) auto 0; text-align: left; }
.tm-does > li { min-width: 0; display: grid; align-content: start; gap: 8px; padding-top: 18px; border-top: 1px solid var(--line-strong); }
.tm-does .tag { justify-self: start; }
.tm-does b { font-weight: 600; font-size: 1.02rem; letter-spacing: -0.01em; }
.tm-does span:not(.tag) { color: var(--ink-3); font-size: 14.5px; line-height: 1.55; }
.tm-cta { justify-content: center; margin-top: clamp(32px, 4vw, 44px); }
.tm-note { max-width: 760px; margin: 28px auto 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-3); text-wrap: pretty; }
.tm-note a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.tm-note a:hover { color: var(--ink); }

/* ---------- Live: pinned and scroll-driven ---------- */
.tm.is-live .tm-board { will-change: transform; }
.tm.is-live .tm-hd, .tm.is-live .tm-col, .tm.is-live .tm-bg { will-change: transform; }
.tm.is-live .tm-steps { display: block; margin-top: 0; }
.tm.is-live .tm-step { border-top: 0; padding-top: 0; display: flex; align-items: center; opacity: 0.3; transition: opacity 0.45s var(--ease); }
.tm.is-live .tm-step.is-active { opacity: 1; }

@media (min-width: 1000px) {
  .tm.is-live .tm-grid { display: grid; grid-template-columns: minmax(280px, 4fr) minmax(0, 8fr); column-gap: clamp(28px, 4vw, 64px); align-items: start; }
  .tm.is-live .tm-pin { grid-column: 2; grid-row: 1; position: sticky; top: 60px; height: calc(100vh - 60px); height: calc(100svh - 60px); display: flex; align-items: center; }
  .tm.is-live .tm-steps { grid-column: 1; grid-row: 1; padding-top: 10vh; padding-bottom: 34vh; }
  .tm.is-live .tm-step { min-height: 78vh; min-height: 78svh; }
  .tm.is-live .tm-step-in { max-width: 400px; }
  .tm.is-live .tm-h { font-size: clamp(1.45rem, 2vw, 1.8rem); }
  .tm.is-live .tm-tx { font-size: 16px; }
}
@media (min-width: 1000px) and (max-width: 1199px) {
  .tm { --tm-sw: 182px; --tm-nw: 56px; --tm-pad: 14px; }
  .tm-lab { font-size: 12px; }
}
/* narrower cards: the slug without its version, so both headers stay the same height */
@media (max-width: 1199px) {
  .tm-slug-v { display: none; }
}
@media (min-width: 640px) and (max-width: 739px) {
  .tm-slug { font-size: 11px; }
}

/* shorter desktop and tablet screens: a more compact card header */
@media (min-width: 640px) and (max-height: 820px) {
  .tm-who { margin-bottom: 10px; }
  .tm-hd { padding-top: 12px; padding-bottom: 8px; }
  .tm-verdict { margin-top: 8px; }
  .tm-word { font-size: 26px; }
  .tm-ptrack { margin-top: 4px; }
  .tm-foot { margin-top: 4px; }
  .tm-legend { margin-top: 10px; }
}

/* stacked: the board pinned under the header, captions scrolling beneath it */
@media (max-width: 999px) {
  .tm-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm.is-live .tm-pin { position: sticky; top: 60px; z-index: 3; padding: 8px 0 14px; background: var(--bg); }
  .tm.is-live .tm-pin::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; background: linear-gradient(var(--bg), color-mix(in srgb, var(--bg) 0%, transparent)); pointer-events: none; }
  .tm.is-live .tm-steps { position: relative; z-index: 1; padding-bottom: calc(var(--tm-win, 40vh) * 0.35); }
  .tm.is-live .tm-step { min-height: var(--tm-win, 40vh); padding-block: 22px; }
  .tm.is-live .tm-step-in { max-width: 560px; }
}

/* phones: interleave the two models on one shared axis, upper bar forest, lower bar scorecard */
@media (max-width: 639px) {
  .tm {
    --tm-rh: clamp(28px, calc((100svh - 560px) / 10), 32px);
    --tm-lw: 110px;     /* label column */
    --tm-nw: 60px;
    --tm-g: 8px;
    --tm-bh: 8px;
    --tm-pad: 12px;
  }
  .tm-board { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 8px; grid-template-areas: "who who" "fh lh" "rows rows" "lg lg"; }
  .tm-who { margin-bottom: 8px; font-size: 13px; }
  .tm-who > span:first-child { font-size: 13px; letter-spacing: 0.06em; }
  .tm-who-x { display: none; }
  .tm-bg-f { grid-area: fh; }
  .tm-bg-l { grid-area: lh; }
  .tm-bg-r { display: block; grid-area: rows; margin-top: 8px; }
  .tm-eq { display: none; }
  .tm-why { grid-area: rows; font-size: 13px; }
  .tm-hd { padding: 10px 12px 9px; }
  .tm-name span { display: none; }
  .tm-name b { font-size: 14px; }
  .tm-slug { display: none; }   /* the slugs are longer than a phone's card is wide */
  .tm-verdict { margin-top: 6px; }
  .tm-word { font-size: 22px; }
  .tm-p { font-size: 14px; }
  .tm-plab { display: none; }
  .tm-ptrack { height: 25px; margin-top: 2px; }
  .tm-ptrack::before, .tm-fill { top: 18px; }
  .tm-thr { top: 12px; }
  .tm-thr span { font-size: 13px; top: -12px; }
  .tm-dot, .tm-dot0 { top: 19px; }
  .tm-foot { margin-top: 5px; font-size: 13px; }
  .tm-acc > span { display: none; }
  .tm.is-live .tm-lv, .tm.is-live .tm-wn { display: none; }
  .tm-col-f, .tm-col-s, .tm-col-l { grid-area: rows; padding: 8px 12px 9px; margin-top: 8px; }
  .tm-col-s { width: calc(var(--tm-lw) + 12px); padding-right: 0; }
  .tm-col-f, .tm-col-l { margin-left: calc(var(--tm-lw) + 8px); padding-left: 4px; }
  .tm-axis { height: 32px; font-size: 13px; }
  .tm-axis-in { top: 15px; }
  .tm-axis-l, .tm-col-l .tm-rows::before { visibility: hidden; }
  .tm-axis-s { display: grid; justify-content: start; align-content: start; gap: 0; padding-top: 0; }
  .tm-axis-s .tm-away, .tm-axis-s .tm-toward { display: none; }
  .tm-key { display: inline-flex !important; align-items: center; gap: 7px; height: 15px; font-size: 13px; color: var(--ink-3); }
  .tm-key i { width: 14px; height: 11px; flex: none; background: linear-gradient(var(--ink-2), var(--ink-2)) 0 0 / 100% 4px no-repeat, linear-gradient(var(--line-strong), var(--line-strong)) 0 7px / 100% 4px no-repeat; border-radius: 1px; }
  .tm-key-l i { background: linear-gradient(var(--line-strong), var(--line-strong)) 0 0 / 100% 4px no-repeat, linear-gradient(var(--ink-2), var(--ink-2)) 0 7px / 100% 4px no-repeat; }
  .tm-col-s .tm-r { justify-items: start; align-content: center; padding-top: 0; }
  .tm-lab { flex-direction: column; align-items: flex-start; gap: 0; height: auto; line-height: calc(var(--tm-rh) / 2); font-size: 13px; }
  .tm-lab span::before { display: none; }
  .tm-lab-b { white-space: normal; width: var(--tm-lw); }
  .tm-gap { display: none; }
  .tm-r::before { display: none; }
  .tm-col-s .tm-r::before { display: block; inset: 0 auto 0 -6px; width: calc(100vw - 52px); }
  .tm-plot, .tm-num { top: 0; height: calc(var(--tm-rh) / 2); }
  .tm-col-l .tm-plot, .tm-col-l .tm-num { top: calc(var(--tm-rh) / 2); left: 0; right: calc(var(--tm-nw) + var(--tm-g)); }
  .tm-col-l .tm-num { left: auto; right: 0; width: var(--tm-nw); justify-items: end; }
  .tm-bar { top: calc(var(--tm-rh) / 4 - var(--tm-bh) / 2); }
  .tm-num { font-size: 13px; line-height: calc(var(--tm-rh) / 2); }
  .tm-ghost { display: none; }
  .tm-legend { margin-top: 8px; font-size: 13px; }
  .tm-legend-x, .tm-legend-g { display: none; }
  .tm-steps { grid-template-columns: minmax(0, 1fr); }
  .tm.is-live .tm-k { font-size: 12px; }
  .tm.is-live .tm-h { font-size: 1.15rem; margin-top: 4px; }
  .tm.is-live .tm-tx { font-size: 15px; margin-top: 6px; line-height: 1.55; }
  .tm-does { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .tm-cta .btn { width: 100%; }
}
.tm:not(.is-live) { --tm-rh: 43px; }
@media (max-width: 639px) {
  .tm:not(.is-live) { --tm-rh: 32px; }
}
@media (max-width: 639px) and (max-height: 740px) {
  .tm-lab span { display: none; }
}
