/* =========================================================================
   TOOL 3 · ROCALC — Robux calculator suite (ported from dgolaus/RoCalc)
   Every selector scoped under #tool-rocalc. Tokens come from core.css.
   Chrome accent remapped green→red for unification; green/amber kept ONLY
   where they carry meaning (good-deal diff = green, ToS caution = amber).
   ========================================================================= */

/* ---------- layout ---------- */
#tool-rocalc .wrap {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 40px clamp(16px, 4vw, 32px) 80px;
}

#tool-rocalc .hero { padding: 0 0 12px; }
#tool-rocalc .hero h1 {
  font-size: 15px; font-weight: 600; margin: 0;
  letter-spacing: -0.01em; color: var(--fg-strong);
}
#tool-rocalc .hero .meta { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

/* sub-nav (tax · gamepass · devex · black market) */
#tool-rocalc .nav { display: inline-flex; flex-wrap: wrap; align-items: baseline; }
#tool-rocalc .nav-item {
  color: var(--muted); text-decoration: none; display: inline-block;
  padding: 2px 4px; border-radius: 2px; cursor: pointer;
  position: relative; transform-origin: center;
  transition: transform 0.30s var(--ease-out), color 0.25s ease, opacity 0.25s ease, text-decoration-color 0.25s ease;
}
#tool-rocalc .nav-item::after { content: ''; position: absolute; inset: -10px -3px; }
#tool-rocalc .nav-item:hover, #tool-rocalc .nav-item:focus-visible { color: var(--fg-strong); transform: scale(1.18); outline: none; }
#tool-rocalc .nav:hover .nav-item:not(:hover),
#tool-rocalc .nav:focus-within .nav-item:not(:focus-visible):not(:hover) { opacity: 0.45; transform: scale(0.9); }
#tool-rocalc .nav-item.is-active {
  color: var(--fg-strong); text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: 5px;
  text-decoration-color: var(--accent);
}
#tool-rocalc .nav-item.is-active[href="#sec-bm"] { text-decoration-color: var(--warn); }
#tool-rocalc .nav-sep { color: var(--dim); margin: 0 6px; user-select: none; transition: opacity 0.25s ease; }
#tool-rocalc .nav:hover .nav-sep, #tool-rocalc .nav:focus-within .nav-sep { opacity: 0.45; }

/* ---------- sections (override core) ---------- */
#tool-rocalc .section { margin-top: 40px; margin-bottom: 0; }
#tool-rocalc .section__head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px; font-size: 12px; color: var(--muted);
}
#tool-rocalc .section__title::before { content: '// '; color: var(--dim); }
#tool-rocalc .section__actions { display: inline-flex; gap: 14px; }
#tool-rocalc .section__desc { color: var(--muted); font-size: 11.5px; margin: 0 0 12px; line-height: 1.55; }

/* ---------- rows (override core) ---------- */
#tool-rocalc .row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line);
}
#tool-rocalc .row + .row { border-top: none; }
#tool-rocalc .row__label { color: var(--fg); font-size: 13px; }
#tool-rocalc .row__value { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
#tool-rocalc .row__value [data-tax-fee],
#tool-rocalc .row__value [data-gp-list],
#tool-rocalc .row__value [data-gp-fee] { color: var(--fg-strong); }
#tool-rocalc .row__sep { color: var(--dim); margin: 0 6px; }

/* ---------- inputs ---------- */
#tool-rocalc .input-with-suffix { display: inline-flex; align-items: baseline; gap: 8px; }
#tool-rocalc .row input {
  background: transparent; border: 0; color: var(--fg-strong);
  font: inherit; font-size: 13px; text-align: right; outline: none;
  border-bottom: 1px solid var(--dim); padding: 2px 6px; width: 200px;
  transition: border-bottom-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  font-variant-numeric: tabular-nums;
}
#tool-rocalc .row input:focus { border-bottom-color: var(--accent); }
#tool-rocalc .row input::placeholder { color: var(--dim); }
#tool-rocalc .suffix, #tool-rocalc .prefix { color: var(--muted); font-size: 12px; }
#tool-rocalc .section--blackmarket .row input:focus { border-bottom-color: var(--warn); }

/* ---------- presets · toggle · text-btn · details ---------- */
#tool-rocalc .presets {
  display: inline-flex; gap: 12px; margin-top: 14px; font-size: 11px;
  color: var(--muted); flex-wrap: wrap; align-items: baseline;
}
#tool-rocalc .presets .label { color: var(--dim); }
#tool-rocalc .preset {
  color: var(--muted); text-decoration: underline; text-decoration-color: var(--dim);
  text-underline-offset: 3px; transition: color 0.15s ease, text-decoration-color 0.15s ease;
  position: relative;
}
#tool-rocalc .preset:hover { color: var(--accent); text-decoration-color: var(--accent); }
#tool-rocalc .preset::after { content: ''; position: absolute; inset: -10px -4px; }

#tool-rocalc .toggle {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  user-select: none; font-size: 11.5px; color: var(--muted);
}
#tool-rocalc .toggle input { position: absolute; opacity: 0; pointer-events: none; }
#tool-rocalc .toggle__switch {
  position: relative; width: 28px; height: 14px;
  background: var(--line-strong); border-radius: 999px; transition: background 0.15s ease;
}
#tool-rocalc .toggle__switch::after {
  content: ''; position: absolute; top: 1px; left: 1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); transition: transform 0.15s ease, background 0.15s ease;
}
#tool-rocalc .toggle input:checked ~ .toggle__switch { background: var(--accent-dim); }
#tool-rocalc .toggle input:checked ~ .toggle__switch::after { transform: translateX(14px); background: var(--accent); }
#tool-rocalc .toggle input:focus-visible ~ .toggle__switch { outline: 1px solid var(--accent); outline-offset: 2px; }

#tool-rocalc .text-btn {
  color: var(--muted); font-size: 11px; text-decoration: underline;
  text-decoration-color: var(--dim); text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease; position: relative;
}
#tool-rocalc .text-btn:hover { color: var(--fg); text-decoration-color: var(--muted); }
#tool-rocalc .text-btn::after { content: ''; position: absolute; inset: -10px -4px; }

/* tooltip */
#tool-rocalc .has-info { position: relative; cursor: help; border-bottom: 1px dotted var(--dim); }
#tool-rocalc .has-info:hover, #tool-rocalc .has-info:focus-visible { border-bottom-color: var(--muted); color: var(--fg-strong); outline: none; }
#tool-rocalc .has-info::after {
  content: attr(data-info);
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 10;
  background: #0a0a0a; color: var(--fg); padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 2px;
  font-size: 11px; width: max-content; max-width: 280px; white-space: normal;
  line-height: 1.55; letter-spacing: -0.002em;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease; transform: translateY(4px);
}
#tool-rocalc .has-info:hover::after, #tool-rocalc .has-info:focus-visible::after { opacity: 1; transform: translateY(0); }

#tool-rocalc details summary {
  cursor: pointer; color: var(--muted); font-size: 11.5px;
  padding: 10px 0; list-style: none; transition: color 0.15s ease;
}
#tool-rocalc details summary::-webkit-details-marker { display: none; }
#tool-rocalc details summary::before { content: '+ '; color: var(--dim); transition: color 0.15s ease; }
#tool-rocalc details[open] summary::before { content: '− '; color: var(--accent); }
#tool-rocalc details summary:hover { color: var(--fg); }
#tool-rocalc details summary:hover::before { color: var(--muted); }

#tool-rocalc .toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; flex-wrap: wrap; gap: 14px;
}
#tool-rocalc .toggle-row .presets { margin: 0; }

/* ---------- black market ---------- */
#tool-rocalc .compare { padding: 4px 0; font-size: 11px; color: var(--dim); text-align: right; margin: 0; }
#tool-rocalc .compare .diff { margin-left: 8px; font-weight: 500; }
#tool-rocalc .compare .diff.positive { color: var(--pos); }
#tool-rocalc .compare .diff.negative { color: var(--neg); }

#tool-rocalc .bm-warning {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; margin-bottom: 14px;
  border: 1px solid var(--warn-dim); border-left: 2px solid var(--warn);
  border-radius: 2px; background: rgba(251, 191, 36, 0.03);
}
#tool-rocalc .bm-warning .icon { color: var(--warn); flex-shrink: 0; margin-top: 2px; }
#tool-rocalc .bm-warning p { margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.55; }
#tool-rocalc .bm-warning strong { color: var(--warn); font-weight: 500; }
#tool-rocalc .bm-sub__title { font-size: 11px; color: var(--muted); margin: 28px 0 4px; font-weight: 500; }
#tool-rocalc .bm-sub__title::before { content: '## '; color: var(--dim); }
#tool-rocalc .bm-sub:first-of-type .bm-sub__title { margin-top: 16px; }

/* ---------- devex warn ---------- */
#tool-rocalc .warn-msg {
  margin: 12px 0 0; padding: 8px 12px; border-left: 2px solid var(--warn);
  color: #fcd9a0; font-size: 11.5px; background: rgba(251, 191, 36, 0.05); border-radius: 2px;
}

/* ---------- footer ---------- */
#tool-rocalc .footer {
  margin-top: 70px; padding-top: 24px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--muted);
}
#tool-rocalc .footer p { margin: 4px 0; }
#tool-rocalc .footer p::before { content: '// '; color: var(--dim); }
#tool-rocalc .footer a {
  color: var(--fg); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--dim); transition: text-decoration-color 0.15s ease;
}
#tool-rocalc .footer a:hover { text-decoration-color: var(--accent); }
#tool-rocalc .footer .sep { margin: 0 8px; color: var(--dim); }

/* ---------- toast (rocalc variant) ---------- */
#tool-rocalc .toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(40px);
  padding: 8px 16px; background: var(--bg-elev);
  border: 1px solid var(--line-strong); color: var(--fg);
  font-size: 12px; border-radius: var(--radius-sm);
  opacity: 0; pointer-events: none;
  transition: transform 0.25s ease, opacity 0.2s ease;
  z-index: 100; max-width: calc(100vw - 32px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#tool-rocalc .toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#tool-rocalc .toast::before { content: '✓ '; color: var(--pos); }
#tool-rocalc .toast[data-type="warn"]::before { content: '⚠ '; color: var(--warn); }

/* ---------- section pulse (red / amber) ---------- */
@keyframes rc-pulse-red {
  0%   { border-bottom-color: var(--dim);    box-shadow: 0 0 0 rgba(255,255,255,0); }
  40%  { border-bottom-color: var(--accent); box-shadow: 0 1px 10px -2px var(--accent-glow); }
  60%  { border-bottom-color: var(--accent); box-shadow: 0 1px 10px -2px var(--accent-glow); }
  100% { border-bottom-color: var(--dim);    box-shadow: 0 0 0 rgba(255,255,255,0); }
}
@keyframes rc-pulse-amber {
  0%   { border-bottom-color: var(--dim);  box-shadow: 0 0 0 rgba(251,191,36,0); }
  40%  { border-bottom-color: var(--warn); box-shadow: 0 1px 10px -2px var(--warn-glow); }
  60%  { border-bottom-color: var(--warn); box-shadow: 0 1px 10px -2px var(--warn-glow); }
  100% { border-bottom-color: var(--dim);  box-shadow: 0 0 0 rgba(251,191,36,0); }
}
#tool-rocalc .section.just-entered .row input:not(:focus) { animation: rc-pulse-red 1s ease-out both; }
#tool-rocalc .section--blackmarket.just-entered .row input:not(:focus) { animation: rc-pulse-amber 1s ease-out both; }
#tool-rocalc .row input.flashing:not(:focus) { animation: rc-pulse-red 0.9s ease-out; }
#tool-rocalc .section--blackmarket .row input.flashing:not(:focus) { animation: rc-pulse-amber 0.9s ease-out; }
#tool-rocalc .section.just-entered .row:nth-of-type(2) input:not(:focus) { animation-delay: 0.08s; }
#tool-rocalc .section.just-entered .row:nth-of-type(3) input:not(:focus) { animation-delay: 0.16s; }
#tool-rocalc .section.just-entered .row:nth-of-type(4) input:not(:focus) { animation-delay: 0.24s; }
#tool-rocalc .section.just-entered .row:nth-of-type(5) input:not(:focus) { animation-delay: 0.32s; }
#tool-rocalc .section.just-entered .row:nth-of-type(6) input:not(:focus) { animation-delay: 0.40s; }

/* ---------- responsive ---------- */
@media (max-width: 540px) {
  #tool-rocalc .wrap { padding: 28px 18px 60px; }
  #tool-rocalc .row { flex-wrap: wrap; gap: 8px; }
  #tool-rocalc .row input { width: 100%; min-width: 0; flex: 1; }
  #tool-rocalc .input-with-suffix { width: 100%; justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  #tool-rocalc .section.just-entered .row input { animation: none !important; }
  #tool-rocalc .nav-item { transition: none !important; }
}
