/* Interstellar Kinetics | /tools: thirteen tools and games. Loaded only on /tools.
   Motion: card flips and meter glow use transform and opacity only, and stop under .motion-off. */

/* ---------- Index ---------- */
.tool-index-wrap { display: grid; gap: 2.2rem; }
.tool-group-h { font-family: var(--sans); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); margin: 0 0 0.9rem; }
.tool-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.tool-tile { position: relative; display: grid; gap: 0.35rem; padding: 1.2rem 1.2rem 1.3rem; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, var(--surface), var(--navy-deep)); color: var(--text); text-decoration: none; transition: border-color 0.25s var(--ease), transform 0.25s var(--ease); }
.tool-tile:hover, .tool-tile:focus-visible { border-color: var(--gold); transform: translateY(-2px); }
.tool-tile strong { font-family: var(--serif); font-size: 1.12rem; font-weight: 400; }
.tool-tile small { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.tt-num { position: absolute; top: 1rem; right: 1.1rem; font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.16em; color: var(--slate-soft); }
.tt-ico { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line-gold); background: radial-gradient(circle at 35% 30%, rgba(201, 168, 76, 0.28), rgba(43, 74, 122, 0.25)); position: relative; margin-bottom: 0.3rem; }
.tt-ico::before { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border: 2px solid var(--gold); border-radius: 50%; }
.tt-price::before, .tt-ltv::before { border-radius: 3px; transform: rotate(45deg); }
.tt-runway::before { width: 18px; height: 10px; border-radius: 0; border-width: 0 0 2px 2px; }
.tt-time::before, .tt-meet::before { border-color: var(--gold-soft); }
.tt-match::before, .tt-fact::before { width: 12px; height: 16px; border-radius: 3px; }
.tt-next::before, .tt-prompt::before { width: 18px; height: 3px; border-width: 0; background: var(--gold); border-radius: 2px; }
.tt-scam::before { width: 0; height: 0; border-radius: 0; border-width: 0 9px 15px; border-color: transparent transparent var(--gold); }
.tt-ready::before, .tt-cases::before { width: 10px; height: 16px; border-radius: 0; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-2px, -2px); }

/* ---------- Tool layout ---------- */
.tool { scroll-margin-top: calc(var(--header-h) + 12px); }
.tool-head { max-width: 760px; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 1.6rem; margin-top: 2rem; align-items: start; }
.tool-form { display: grid; gap: 1rem; padding: 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.field { display: grid; gap: 0.35rem; }
.field label, .field legend { font-family: var(--sans); font-size: 0.9rem; font-weight: 600; color: var(--text); }
.field small { color: var(--muted); font-size: 0.82rem; }
.field input[type="number"], .field input[type="text"], .field select, .field textarea, .tb-row-in input {
  width: 100%; min-height: 44px; padding: 0.6rem 0.8rem; border-radius: 10px; border: 1px solid var(--line); background: var(--navy-deep); color: var(--text); font: 1rem var(--sans);
}
.field textarea { resize: vertical; line-height: 1.45; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .tb-row-in input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.field output { color: var(--gold); font-weight: 700; }
.field-range input[type="range"] { width: 100%; min-height: 32px; accent-color: var(--gold); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field-check { display: flex; align-items: center; gap: 0.6rem; }
.field-check input { width: 22px; height: 22px; accent-color: var(--gold); }
.checks { border: 0; padding: 0; margin: 0; display: grid; gap: 0.55rem; }
.checks legend { margin-bottom: 0.5rem; }
.checks label { display: flex; align-items: center; gap: 0.6rem; font-weight: 400; color: var(--muted); min-height: 28px; }
.checks input { width: 20px; height: 20px; flex: none; accent-color: var(--gold); }

.tool-result { position: sticky; top: calc(var(--header-h) + 16px); display: grid; gap: 0.7rem; padding: 1.6rem; border: 1px solid var(--line-gold); border-radius: var(--radius); background: radial-gradient(ellipse 80% 70% at 85% 0%, rgba(43, 74, 122, 0.45), transparent 70%), var(--navy-deep); }
.tool-big { font-family: var(--serif); font-size: clamp(2.2rem, 5vw, 3.2rem); line-height: 1.05; color: var(--gold-soft); margin: 0; overflow-wrap: anywhere; }
.tool-sub { color: var(--muted); margin: 0; }
.tool-note { color: var(--muted); font-size: 0.95rem; margin: 0; }
.tool-callout { margin: 0; padding: 0.85rem 1rem; border-left: 3px solid var(--gold); background: rgba(201, 168, 76, 0.08); border-radius: 0 10px 10px 0; }
.tool-callout:empty { display: none; }
.tool-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0.3rem 0; }
.tool-stats div { padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tool-stats dt { font-family: var(--sans); font-size: 0.74rem; letter-spacing: 0.06em; color: var(--muted); }
.tool-stats dd { margin: 0.2rem 0 0; font-family: var(--serif); font-size: 1.25rem; color: var(--text); overflow-wrap: anywhere; }
.tool-math { margin-top: 1.2rem; max-width: 860px; border-top: 1px solid var(--line); padding-top: 0.9rem; color: var(--muted); }
.tool-math summary { cursor: pointer; color: var(--gold); font-family: var(--sans); font-size: 0.9rem; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.tool-math p { margin: 0.5rem 0 0; }

/* Bars */
.tool-bars { display: grid; gap: 0.55rem; margin: 0.3rem 0; }
.tb-row { display: grid; grid-template-columns: 7.5rem 1fr auto; gap: 0.7rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
.tb-row b { color: var(--text); font-weight: 600; }
.tb-track, .ratio-track, .nw-track { position: relative; height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.tb-fill, .ratio-fill, .nw-fill, .q-bar { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); background: var(--slate-soft); border-radius: 6px; transition: transform 0.5s var(--ease); }
.tb-fill.gold, .ratio-fill, .nw-fill, .q-bar { background: linear-gradient(90deg, var(--gold-ink), var(--gold-soft)); }
.ratio { margin: 0.3rem 0; }
.ratio-one { position: absolute; top: 0; bottom: 0; left: 20%; width: 2px; background: var(--text); opacity: 0.6; }

/* Runway chart */
.tool-chart { margin: 0.2rem 0; }
.tool-chart svg { width: 100%; height: auto; display: block; }
.tool-chart figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }
.rc-area { fill: rgba(201, 168, 76, 0.16); }
.rc-line { fill: none; stroke: var(--gold); stroke-width: 2.5; stroke-linejoin: round; }
.rc-zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 5 5; }
.rc-dot { fill: #E0574F; }
.rc-lab { fill: var(--muted); font: 11px var(--sans); }

/* Time-back table */
.tool-grid-wide { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.tb-table { display: grid; gap: 0.5rem; }
.tb-head, .tb-row-in { display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem 6.5rem 2.75rem; gap: 0.5rem; align-items: center; }
.tb-head { font-family: var(--sans); font-size: 0.74rem; letter-spacing: 0.04em; color: var(--muted); }
#t-rows { display: grid; gap: 0.5rem; }
.tb-x { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.tb-x:hover, .tb-x:focus-visible { color: var(--gold); border-color: var(--gold); }
#t-add { justify-self: start; }

/* Meeting meter */
.meter-cost { font-variant-numeric: tabular-nums; }
.meter-time { font-family: var(--sans); font-variant-numeric: tabular-nums; color: var(--text); }
.meter.is-running { border-color: var(--gold); }
.meter.is-running .meter-cost { animation: meter-glow 1.6s ease-in-out infinite alternate; }
@keyframes meter-glow { from { opacity: 0.82; } to { opacity: 1; } }

/* ---------- 07 Term Match ---------- */
.game-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.5rem; margin: 1.6rem 0 1rem; font-family: var(--sans); color: var(--muted); }
.game-bar b { color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.game-bar .btn { margin-left: auto; }
.match-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; perspective: 1200px; }
.mcard { position: relative; min-height: 150px; padding: 0; border: 0; background: transparent; cursor: pointer; color: var(--text); text-align: left; border-radius: 14px; }
.mcard:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.mcard-in { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.55s var(--ease); }
.mcard.is-up .mcard-in { transform: rotateY(180deg); }
.mcard-back, .mcard-face { position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; justify-content: center; }
.mcard-back { align-items: center; border: 1px solid var(--line-gold); background: radial-gradient(circle at 50% 40%, rgba(43, 74, 122, 0.75), var(--navy-deep) 72%); }
.mcard-logo { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--gold); color: var(--gold); font-family: var(--serif); font-size: 1.2rem; transition: transform 0.3s var(--ease); }
.mcard:hover .mcard-logo { transform: scale(1.08); }
.mcard-face { transform: rotateY(180deg); padding: 0.85rem 0.9rem; gap: 0.35rem; border: 1px solid var(--slate-soft); background: var(--surface); font-size: 0.88rem; line-height: 1.38; }
.mcard-term .mcard-face { background: linear-gradient(160deg, var(--surface-2), var(--surface)); font-family: var(--serif); font-size: 1.15rem; }
.mcard-face small { font-family: var(--sans); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); }
.mcard.is-done .mcard-face { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 10px 30px -16px rgba(201, 168, 76, 0.8); }
.mcard.is-done { cursor: default; }
.match-learn { margin-top: 1.2rem; min-height: 4.5rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.match-fact { margin: 0; }
.match-fact strong { color: var(--gold-soft); font-weight: 400; font-family: var(--serif); }
.match-win { margin: 0.6rem 0 0; color: var(--gold); font-family: var(--serif); font-size: 1.2rem; }

/* ---------- 08 Next-Word Machine ---------- */
.nw-text { font-family: var(--serif); font-size: clamp(1.3rem, 3vw, 1.7rem); line-height: 1.4; min-height: 4.5rem; margin: 0.3rem 0 0.6rem; }
.nw-last { color: var(--gold-soft); }
.nw-cands { display: grid; gap: 0.45rem; }
.nw-cand { display: grid; grid-template-columns: minmax(7rem, auto) 1fr 3rem; align-items: center; gap: 0.7rem; min-height: 44px; padding: 0.4rem 0.8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--navy-deep); color: var(--text); font: 1rem var(--sans); cursor: pointer; text-align: left; }
.nw-cand:hover, .nw-cand:focus-visible { border-color: var(--gold); outline: none; }
.nw-pct { text-align: right; color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.nw-lessons { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.7rem; color: var(--muted); }
.nw-lessons strong { color: var(--text); }

/* ---------- Quizzes (09 and 13) ---------- */
.quiz { max-width: 820px; margin-top: 2rem; padding: clamp(1.2rem, 3vw, 2rem); border: 1px solid var(--line-gold); border-radius: var(--radius); background: radial-gradient(ellipse 70% 60% at 90% 0%, rgba(43, 74, 122, 0.4), transparent 70%), var(--surface); display: grid; gap: 1rem; transition: border-color 0.3s var(--ease); }
.quiz-top { display: flex; justify-content: space-between; font-family: var(--sans); color: var(--muted); }
.quiz-top b { color: var(--gold-soft); }
.quiz-progress { position: relative; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.quiz-claim { font-family: var(--serif); font-size: clamp(1.2rem, 2.6vw, 1.5rem); line-height: 1.4; margin: 0; }
.quiz.is-right { border-color: #3DA56A; }
.quiz.is-wrong { border-color: #E0574F; }
.quiz-verdict { font-family: var(--sans); font-weight: 700; margin: 0 0 0.3rem; }
.is-right .quiz-verdict { color: #6FD39A; }
.is-wrong .quiz-verdict { color: #FF8A82; }
.quiz-explain p { margin: 0; color: var(--muted); }
.quiz-explain:empty { display: none; }
.scam-msg { border: 1px solid var(--line); border-radius: 12px; background: var(--navy-deep); padding: 1rem 1.1rem; }
.scam-from { margin: 0 0 0.4rem; font-family: var(--sans); font-size: 0.82rem; letter-spacing: 0.04em; color: var(--gold); }
.scam-msg .quiz-claim { font-family: var(--sans); font-size: 1.05rem; }

/* ---------- 10 Prompt Builder ---------- */
.prompt-out { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 0.92rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; max-height: 26rem; overflow: auto; }
.prompt-out:focus-visible { outline: 2px solid var(--gold); }
.prompt-meter { display: grid; grid-template-columns: auto 1fr auto; gap: 0.7rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
.prompt-meter b { color: var(--gold-soft); }

/* ---------- 11 Use cases ---------- */
.uc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.8rem; max-height: 40rem; overflow: auto; }
.uc-intro p { margin: 0; color: var(--gold-soft); font-family: var(--serif); }
.uc-item { padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.uc-item h3 { font-family: var(--serif); font-weight: 400; font-size: 1.1rem; margin: 0 0 0.35rem; }
.uc-item p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.94rem; }
.uc-item strong { color: var(--text); }
.uc-watch strong { color: var(--gold); }

/* ---------- 12 Readiness ---------- */
.rd-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.6rem; counter-reset: rd; }
.rd-q fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 0.75rem 0.9rem; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.2rem; }
.rd-q legend { float: left; width: 100%; padding: 0; margin-bottom: 0.4rem; font-size: 0.96rem; color: var(--text); }
.rd-fn { display: inline-block; margin-right: 0.5rem; padding: 0.05rem 0.5rem; border-radius: 999px; border: 1px solid var(--line-gold); font-family: var(--sans); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); vertical-align: 2px; }
.rd-opt { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 32px; color: var(--muted); cursor: pointer; }
.rd-opt input { width: 20px; height: 20px; accent-color: var(--gold); }
.rd-funcs { display: grid; gap: 0.45rem; }
.rd-fx { display: grid; grid-template-columns: 5.5rem 1fr 2.5rem; gap: 0.6rem; align-items: center; font-size: 0.88rem; color: var(--muted); }
.rd-fx b { color: var(--text); text-align: right; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .tool-grid, .tool-grid-wide { grid-template-columns: 1fr; }
  .tool-result { position: static; }
  .match-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .match-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mcard { min-height: 140px; }
  .tool-stats, .field-pair { grid-template-columns: 1fr; }
  .tb-head { display: none; }
  .tb-row-in { grid-template-columns: 1fr 1fr 44px; padding: 0.6rem; border: 1px solid var(--line); border-radius: 10px; }
  .tb-row-in .tb-name { grid-column: 1 / -1; }
  .tb-row { grid-template-columns: 6rem 1fr; }
  .tb-row b { grid-column: 2; font-size: 0.8rem; }
  .nw-cand { grid-template-columns: minmax(6rem, auto) 1fr 2.6rem; }
  .game-bar .btn { margin-left: 0; }
}

/* ---------- Motion off ---------- */
html.motion-off .mcard-in, html.motion-off .tb-fill, html.motion-off .ratio-fill, html.motion-off .nw-fill, html.motion-off .q-bar, html.motion-off .tool-tile { transition: none !important; }
html.motion-off .meter.is-running .meter-cost { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .mcard-in, .tb-fill, .ratio-fill, .nw-fill, .q-bar, .tool-tile { transition: none !important; }
}
