/* ==========================================================================
   Math Tools — assets/math-tools.css
   Scoped under .mt-*. Reuses site tokens from style.css / home.css.
   Playful, animated, "class 1-5 friendly" visual language layered on top
   of the existing mv-shelf / mv-feature-card system so it matches PDF Tools
   and Photo Tools, but with extra motion & colour kids enjoy.
   ========================================================================== */

/* ---------------------------------------------------------------------- */
/* 0. PAGE SHELL — matches .vt-shell from visual-tools.css so this page    */
/*    doesn't depend on a stylesheet it doesn't load.                      */
/* ---------------------------------------------------------------------- */
.vt-shell{
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ---------------------------------------------------------------------- */
/* 1. HERO — floating math symbols + bouncy title                          */
/* ---------------------------------------------------------------------- */
.mt-hero{
  position: relative;
  max-width: 760px;
  margin: 6px auto 8px;
  text-align: center;
  padding: 18px 16px 4px;
  overflow: visible;
}

.mt-hero-symbols{
  position: absolute;
  inset: -40px -10px auto -10px;
  height: 240px;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.mt-symbol{
  position: absolute;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--mt-c, var(--accent));
  opacity: .16;
  animation: mt-float 7s ease-in-out infinite;
  will-change: transform;
  user-select: none;
}
html[data-theme="dark"] .mt-symbol{ opacity: .22; }
.mt-symbol:nth-child(1){ top: 6%;  left: 4%;   font-size: 2.6rem; --mt-c: var(--accent-3); animation-delay: 0s; }
.mt-symbol:nth-child(2){ top: 60%; left: 10%;  font-size: 1.8rem; --mt-c: var(--accent-2); animation-delay: 1.1s; }
.mt-symbol:nth-child(3){ top: 12%; right: 6%;  font-size: 3rem;   --mt-c: var(--accent);   animation-delay: .5s; }
.mt-symbol:nth-child(4){ top: 66%; right: 12%; font-size: 2rem;   --mt-c: var(--accent-3); animation-delay: 1.7s; }
.mt-symbol:nth-child(5){ top: 2%;  left: 42%;  font-size: 1.6rem; --mt-c: var(--accent-2); animation-delay: 2.2s; }
.mt-symbol:nth-child(6){ top: 74%; left: 46%;  font-size: 2.2rem; --mt-c: var(--accent);   animation-delay: .9s; }
.mt-symbol:nth-child(7){ top: 34%; left: 1%;   font-size: 1.5rem; --mt-c: var(--accent);   animation-delay: 2.8s; }
.mt-symbol:nth-child(8){ top: 30%; right: 2%;  font-size: 1.7rem; --mt-c: var(--accent-3); animation-delay: 1.4s; }

@keyframes mt-float{
  0%, 100%{ transform: translateY(0) rotate(0deg); }
  50%{ transform: translateY(-16px) rotate(8deg); }
}
@media (prefers-reduced-motion: reduce){
  .mt-symbol{ animation: none; }
}

.mt-hero > *{ position: relative; z-index: 1; }

.mt-hero h1{
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.01em;
  margin: 14px 0 10px;
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-3) 50%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: mt-shine 6s ease-in-out infinite;
  background-size: 200% auto;
}
@keyframes mt-shine{
  0%, 100%{ background-position: 0% center; }
  50%{ background-position: 100% center; }
}
.mt-hero p{ color: var(--ink-soft); font-size: 1.02rem; line-height: 1.6; max-width: 560px; margin: 0 auto; }

.mt-hero-badges{
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin: 18px 0 4px;
}
.mt-badge{
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  animation: mt-pop .5s ease backwards;
}
.mt-badge:nth-child(1){ animation-delay: .05s; }
.mt-badge:nth-child(2){ animation-delay: .15s; }
.mt-badge:nth-child(3){ animation-delay: .25s; }
.mt-badge:nth-child(4){ animation-delay: .35s; }
@keyframes mt-pop{
  from{ opacity: 0; transform: translateY(8px) scale(.9); }
  to{ opacity: 1; transform: translateY(0) scale(1); }
}

.mt-eyebrow{
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: .82rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  padding: 6px 14px;
  border-radius: 999px;
  animation: mt-wiggle 3.2s ease-in-out infinite;
}
@keyframes mt-wiggle{
  0%, 92%, 100%{ transform: rotate(0deg); }
  94%{ transform: rotate(-4deg); }
  96%{ transform: rotate(4deg); }
  98%{ transform: rotate(-2deg); }
}

/* ---------------------------------------------------------------------- */
/* 2. CATEGORY PILLS — quick filter row, chunky & tappable for small hands  */
/* ---------------------------------------------------------------------- */
.mt-catbar{
  display: flex; flex-wrap: wrap; justify-content: center; gap: 9px;
  max-width: 920px; margin: 26px auto 6px;
}
.mt-cat-btn{
  font-family: var(--font-body);
  font-weight: 700; font-size: .86rem;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.mt-cat-btn:hover{ transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.mt-cat-btn.is-active{
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px) scale(1.03);
}

/* ---------------------------------------------------------------------- */
/* 3. TOOL CARDS — bouncy hover, playful icon chip, "Show Steps" chip      */
/* ---------------------------------------------------------------------- */
.mt-shelf{ margin-bottom: 38px; scroll-margin-top: 90px; }
.mt-shelf:last-child{ margin-bottom: 6px; }

.mt-card{
  cursor: pointer;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, border-color .2s ease;
}
.mt-card:hover{ transform: translateY(-4px) scale(1.015); }
.mt-card:active{ transform: translateY(-1px) scale(.99); }

.mt-card .mv-feature-icon{
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.mt-card:hover .mv-feature-icon{ transform: rotate(-8deg) scale(1.12); }

.mt-steps-chip{
  position: absolute; top: 16px; right: 16px;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .64rem; font-weight: 700; letter-spacing: .02em;
  padding: 4px 9px 4px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--success) 16%, var(--surface));
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 30%, var(--border));
}
.mt-steps-chip svg{ width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2.4; }

/* stagger the pop-in of cards within a shelf */
.mt-shelf-grid .mv-reveal{ transition-delay: calc(var(--mt-i, 0) * 45ms); }

/* ---------------------------------------------------------------------- */
/* 4. TOOL MODAL — the "workspace" that opens per tool                     */
/* ---------------------------------------------------------------------- */
.mt-overlay{
  position: fixed; inset: 0;
  background: rgba(10, 10, 20, .52);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.mt-overlay.is-open{ opacity: 1; pointer-events: auto; }

.mt-modal{
  width: 100%; max-width: 560px;
  max-height: min(86vh, 720px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 24px);
  box-shadow: var(--shadow-lg);
  padding: 26px 24px 22px;
  position: relative;
  transform: translateY(18px) scale(.97);
  opacity: 0;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
}
.mt-overlay.is-open .mt-modal{ transform: translateY(0) scale(1); opacity: 1; }

.mt-modal-close{
  position: absolute; top: 16px; right: 16px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-soft);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
.mt-modal-close:hover{ transform: rotate(90deg); background: var(--accent); color: var(--accent-ink); }
.mt-modal-close svg{ width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }

.mt-modal-head{ display: flex; align-items: center; gap: 12px; margin-bottom: 6px; padding-right: 40px; }
.mt-modal-icon{
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 14px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--mt-tier, var(--accent)) 16%, var(--surface-2));
  color: var(--mt-tier, var(--accent));
  animation: mt-pop .35s ease;
}
.mt-modal-icon svg{ width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mt-modal-head h3{ font-family: var(--font-display); font-size: 1.2rem; font-weight: 800; margin: 0; color: var(--ink); }
.mt-modal-head p{ font-size: .82rem; color: var(--ink-faint); margin: 2px 0 0; }

.mt-modal-body{ margin-top: 18px; }

.mt-field-row{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.mt-field-row.mt-field-1{ grid-template-columns: 1fr; }
.mt-field{ display: flex; flex-direction: column; gap: 6px; }
.mt-field label{ font-size: .78rem; font-weight: 700; color: var(--ink-soft); }
.mt-field input, .mt-field select{
  font-family: var(--font-body);
  font-size: .95rem;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.mt-field input:focus, .mt-field select:focus{
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.mt-toggle-row{
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin: 16px 0 4px;
  padding: 11px 14px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.mt-toggle-row span{ font-size: .85rem; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 7px; }
.mt-switch{
  position: relative; width: 42px; height: 24px; flex-shrink: 0;
  border-radius: 999px; background: var(--border);
  border: none; cursor: pointer;
  transition: background .2s ease;
}
.mt-switch::after{
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.mt-switch.is-on{ background: var(--success); }
.mt-switch.is-on::after{ transform: translateX(18px); }

.mt-calc-btn{
  width: 100%;
  margin-top: 18px;
  padding: 13px 16px;
  border: none; border-radius: 13px;
  font-family: var(--font-display); font-weight: 700; font-size: .96rem;
  background: linear-gradient(100deg, var(--accent), var(--accent-3));
  color: var(--accent-ink);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.mt-calc-btn:hover{ transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.mt-calc-btn:active{ transform: translateY(0) scale(.98); }
.mt-calc-btn svg{ width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.mt-result{
  margin-top: 16px;
  border-radius: 13px;
  border: 1.5px dashed var(--border);
  background: var(--surface-2);
  padding: 14px 16px;
  font-size: .85rem;
  color: var(--ink-soft);
  line-height: 1.6;
  display: none;
}
.mt-result.is-shown{ display: block; animation: mt-result-in .3s ease; }
.mt-result.mt-result-error{
  border-style: solid;
  border-color: color-mix(in srgb, var(--danger, #e5484d) 45%, var(--border));
  background: color-mix(in srgb, var(--danger, #e5484d) 10%, var(--surface-2));
  color: var(--danger, #e5484d);
}
.mt-result.mt-result-error strong{ color: inherit; }
@keyframes mt-result-in{ from{ opacity: 0; transform: translateY(6px); } to{ opacity: 1; transform: translateY(0); } }
.mt-result strong{ color: var(--ink); }
.mt-result .mt-steps-note{
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border);
  font-size: .78rem; color: var(--ink-faint); display: flex; gap: 7px; align-items: flex-start;
}
.mt-result .mt-steps-note svg{ width: 15px; height: 15px; flex-shrink: 0; stroke: var(--accent-2); fill: none; stroke-width: 2; margin-top: 1px; }

/* ---------------------------------------------------------------------- */
/* 5. FOOTER STRIP + misc                                                  */
/* ---------------------------------------------------------------------- */
.mt-foot-note{
  text-align: center; max-width: 640px; margin: 10px auto 0;
  font-size: .82rem; color: var(--ink-faint); line-height: 1.6;
}

@media (max-width: 640px){
  .mt-field-row{ grid-template-columns: 1fr; }
  .mt-hero-symbols{ display: none; }
  .mt-modal{ padding: 22px 18px 18px; }
}
