/* App-level CSS that supplements Tailwind. Kept tiny on purpose. */

/* ---------- Self-hosted Nunito (variable font, covers all weights) ---------- */
/* Latin subset — covers ~99% of our text. */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/assets/fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Latin Extended — accented characters, math symbols, etc. */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/assets/fonts/nunito-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Smooth scroll, but only when the user hasn't requested reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Range input polish (Tailwind doesn't fully restyle range thumbs). */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 9999px;
  background: linear-gradient(to right, #10b981 var(--range-fill, 80%), rgba(148, 163, 184, .35) var(--range-fill, 80%));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 18px; width: 18px;
  border-radius: 9999px;
  background: #fff;
  border: 2px solid #10b981;
  box-shadow: 0 2px 6px rgba(16, 185, 129, .3);
  cursor: pointer;
  transition: transform .15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
input[type="range"]::-moz-range-thumb {
  height: 18px; width: 18px;
  border-radius: 9999px;
  background: #fff;
  border: 2px solid #10b981;
  box-shadow: 0 2px 6px rgba(16, 185, 129, .3);
  cursor: pointer;
}

/* Dropzone "active" state when a file is being dragged over it. */
#dropzone.is-dragover {
  border-color: #10b981;
  background-color: rgba(16, 185, 129, .08);
  transform: scale(1.01);
}
.dark #dropzone.is-dragover { background-color: rgba(16, 185, 129, .12); }

/* Toggle switch checked state (driven by aria-checked). */
[role="switch"][aria-checked="true"] { background-color: #10b981 !important; }
[role="switch"][aria-checked="true"] > span { transform: translateX(20px); }

/* Reveal page once theme is set (avoids flash on dark/light reload). */
html.theme-ready .no-fouc { visibility: visible; }

/* Toasts */
.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.4);
  animation: toast-in .25s ease-out, toast-out .25s ease-in 2.6s forwards;
}
.dark .toast { background: #f8fafc; color: #0f172a; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px) }   to { opacity: 1; transform: translateY(0) } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0)  }   to { opacity: 0; transform: translateY(8px) } }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   OWL MASCOT
   ============================================================ */

/* Default idle animation: gentle breathing + occasional blink. */
.owl { transform-origin: center bottom; }
.owl-body { transform-origin: 48px 48px; }
.owl-shadow { transform-origin: center; }
.owl-lid { transform-origin: center; }

@media (prefers-reduced-motion: no-preference) {
  .owl .owl-body  { animation: owl-breathe 4.6s ease-in-out infinite; }
  .owl .owl-shadow{ animation: owl-shadow 4.6s ease-in-out infinite; }
  .owl .owl-lid-left, .owl .owl-lid-right { animation: owl-blink 6.5s ease-in-out infinite; }
}

@keyframes owl-breathe {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  50%      { transform: scaleY(1.02) scaleX(0.99); }
}
@keyframes owl-shadow {
  0%, 100% { transform: scaleX(1); opacity: 0.18; }
  50%      { transform: scaleX(0.92); opacity: 0.22; }
}
@keyframes owl-blink {
  /* Tiny window where the eyelid expands, then snaps back. */
  0%, 92%, 100% { transform: scaleY(0); }
  94%, 96%      { transform: scaleY(11); }
}

/* Hover: a quick happy bob. */
@media (prefers-reduced-motion: no-preference) {
  a:hover .owl, .owl:hover { animation: owl-bob 0.6s ease-out; }
}
@keyframes owl-bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  30%      { transform: translateY(-3px) rotate(-3deg); }
  60%      { transform: translateY(0)    rotate(2deg); }
}

/* Working state: faster blink + tiny shake. */
.owl.is-working .owl-lid-left, .owl.is-working .owl-lid-right {
  animation: owl-blink 1.4s ease-in-out infinite !important;
}
@media (prefers-reduced-motion: no-preference) {
  .owl.is-working { animation: owl-shake 0.5s ease-in-out infinite; }
}
@keyframes owl-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-1px); }
  75%      { transform: translateX(1px); }
}

/* Happy state: bouncing + sparkles appear. */
@media (prefers-reduced-motion: no-preference) {
  .owl.is-happy { animation: owl-happy-bounce 1s ease-in-out infinite; }
}
.owl.is-happy .owl-sparkles { opacity: 1; }
.owl.is-happy .owl-sparkles .sparkle {
  transform-origin: center;
  animation: sparkle-pop 1.4s ease-in-out infinite;
}
.owl.is-happy .owl-sparkles .sparkle:nth-child(2) { animation-delay: 0.2s; }
.owl.is-happy .owl-sparkles .sparkle:nth-child(3) { animation-delay: 0.4s; }
.owl.is-happy .owl-sparkles .sparkle:nth-child(4) { animation-delay: 0.6s; }
.owl.is-happy .owl-sparkles .sparkle:nth-child(5) { animation-delay: 0.3s; }
.owl.is-happy .owl-sparkles .sparkle:nth-child(6) { animation-delay: 0.7s; }
@keyframes owl-happy-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
@keyframes sparkle-pop {
  0%, 100% { transform: scale(0); opacity: 0; }
  40%, 60% { transform: scale(1); opacity: 1; }
}

/* Confused state: head tilt + question marks appear. */
.owl.is-confused .owl-question { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .owl.is-confused { animation: owl-tilt 3.5s ease-in-out infinite; }
  .owl.is-confused .owl-question text {
    animation: question-float 2.5s ease-in-out infinite;
  }
}
@keyframes owl-tilt {
  0%, 100% { transform: rotate(0); }
  50%      { transform: rotate(-6deg); }
}
@keyframes question-float {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50%      { transform: translateY(-3px); opacity: 1; }
}

/* ---------- Snappy interactions ---------- */
/* Slight press-down on actionable elements — gives the UI a tactile feel. */
button:active, [role="button"]:active, label:has(input[type="radio"]):active {
  transform: scale(0.98);
}
button, [role="button"] { transition: transform .08s ease; }

/* Show focus rings only for keyboard users, not on click. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid #10b981;
  outline-offset: 2px;
  border-radius: 6px;
}

/* Smoother number-input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { opacity: 0.4; }

/* Print: don't waste ink on chrome. */
@media print {
  header, footer, #dropzone, #options, #result, #historyPanel, #toast, .no-print { display: none !important; }
  body { background: white !important; color: black !important; }
}
