/* ============================================================
   EmbroidAI — Minimal custom CSS
   Tailwind handles all layout/colors/spacing/typography.
   This file only defines animations and components that can't
   be expressed as utility classes.
   ============================================================ */

/* ---- Keyframe Animations ---- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes ping { 75%, 100% { transform: scale(2); opacity: 0; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes popin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes kenburns {
  0% { transform: scale(1.08) translate(0,0); }
  50% { transform: scale(1.16) translate(-1.5%,1.2%); }
  100% { transform: scale(1.1) translate(1.5%,-1%); }
}
@keyframes sweep {
  0% { background-position: 140% 0; }
  100% { background-position: -40% 0; }
}
@keyframes goldflow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ---- Spinner (route loader) ---- */
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(217,119,6,.35);
  border-top-color: #B45309;
  animation: spin .7s linear infinite;
}

/* ---- Route Loader Overlay ---- */
#routeLoader {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(249,249,255,.0);
  pointer-events: none; opacity: 0;
  transition: opacity .18s;
}
#routeLoader.show {
  opacity: 1;
  background: rgba(249,249,255,.55);
  backdrop-filter: blur(2px);
}

/* ---- Full-Screen Loader ---- */
#loader {
  position: fixed; inset: 0;
  background: rgba(15,17,22,.82);
  backdrop-filter: blur(3px);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 22px; z-index: 50;
}
#loader.show { display: flex; }
.loom { position: relative; width: 84px; height: 84px; }
.loom span {
  position: absolute; inset: 0;
  border: 4px solid transparent; border-radius: 50%;
}
.loom span:nth-child(1) { border-top-color: #D97706; animation: spin 1.1s linear infinite; }
.loom span:nth-child(2) { inset: 9px; border-right-color: #059669; animation: spin 1.6s linear infinite reverse; }
.loom span:nth-child(3) { inset: 18px; border-bottom-color: #e0a13a; animation: spin .8s linear infinite; }
.loom i {
  position: absolute; inset: 34px;
  background: #D97706; border-radius: 50%;
  opacity: .85; animation: pulse 1.3s ease-in-out infinite;
}
#loader .lmsg { color: #ecf1ff; font-size: 15px; text-align: center; max-width: 340px; line-height: 1.5; }
#loader .lsub { color: #98a0b0; font-size: 13px; }

/* ---- Toast System ---- */
#toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 10px; max-width: 340px;
}
@media (max-width: 380px) {
  #toasts { right: 10px; bottom: 10px; max-width: calc(100vw - 20px); }
}
.toast {
  background: #fff;
  border: 1px solid #e5e0d8;
  border-left: 4px solid #D97706;
  border-radius: 10px;
  box-shadow: 0 20px 40px -12px rgba(15,23,42,.16);
  padding: 13px 15px; font-size: 14px;
  animation: slidein .2s ease;
}
.toast.ok { border-left-color: #059669; }
.toast.err { border-left-color: #ba1a1a; }
.toast.info { border-left-color: #565e74; }
.toast b { display: block; margin-bottom: 2px; }

/* ---- Before/After Slider ---- */
.ba {
  position: relative; width: 100%; max-width: 560px;
  margin: 14px auto 4px; border-radius: 16px; overflow: hidden;
  border: 1px solid #2a3140; user-select: none;
  touch-action: none; background: #0d0f14;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.ba img { display: block; width: 100%; height: auto; transition: opacity .3s; }
.ba .after { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.ba .clip {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 50%; overflow: hidden;
  border-right: 2px solid #D97706;
}
.ba .clip img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.ba .handle {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 3px;
  background: linear-gradient(135deg, #D97706, #B45309);
  cursor: ew-resize; transform: translateX(-1px);
  display: flex; align-items: center; justify-content: center;
  transition: .2s;
}
.ba .handle:hover { width: 5px; background: linear-gradient(135deg, #B45309, #D97706); }
.ba .handle:focus-visible {
  outline: 2px solid #D97706; outline-offset: 3px;
  width: 5px; background: linear-gradient(135deg, #B45309, #D97706);
}
.ba .knob {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #D97706, #B45309);
  color: #231702;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(217,119,6,.35);
  pointer-events: none;
}
.ba .knob::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.3);
  pointer-events: none;
}
.ba .tag {
  position: absolute; top: 12px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px;
  color: #fff; background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px); padding: 4px 10px; border-radius: 8px;
  pointer-events: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.ba .tag.l { left: 12px; }
.ba .tag.r { right: 12px; }

/* ---- Layer Row Overrides (Studio) ---- */
.layerrow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(145deg, #161619, #0f1114);
  border: 1px solid #2a2a2e; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; transition: .2s;
}
.layerrow:hover { border-color: #3a4452; }
.layerrow select, .layerrow input[type=range] {
  background: #1c1c1f; color: #eee;
  border: 1px solid #333; border-radius: 6px;
  padding: 6px 8px; font-size: 13px;
}
.layerrow .lbl { font-size: 12px; color: #98a0b0; font-weight: 500; }
.layerrow .sw {
  width: 24px; height: 24px; border-radius: 5px; margin-right: 2px;
  border: 1px solid rgba(0,0,0,.5); vertical-align: middle;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}

/* ---- Scroll Reveal ---- */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }
.reveal.d1 { transition-delay: .08s; }
.reveal.d2 { transition-delay: .16s; }
.reveal.d3 { transition-delay: .24s; }
.reveal.d4 { transition-delay: .32s; }
.reveal.d5 { transition-delay: .40s; }
.reveal.d6 { transition-delay: .48s; }

/* ---- Image Fade-In ---- */
img.fade { opacity: 0; transition: opacity .7s ease; }
img.fade.loaded { opacity: 1; }

/* ---- Ken Burns Hero ---- */
.kb {
  position: relative; overflow: hidden; border-radius: 18px;
  box-shadow: 0 20px 40px -12px rgba(15,23,42,.16);
}
.kb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  animation: kenburns 18s ease-in-out infinite alternate;
}
.kb::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.28) 48%, transparent 66%);
  background-size: 250% 100%;
  animation: sweep 6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .kb img, .kb::after { animation: none; } }

/* ---- Signed-In Pill ---- */
#signedPill {
  position: fixed; right: 18px; bottom: 18px; z-index: 50;
  background: #fff; border: 1px solid #e5e0d8;
  box-shadow: 0 2px 8px -2px rgba(15,23,42,.04);
  border-radius: 999px; padding: 9px 16px;
  font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  animation: popin .4s ease;
}
#signedPill .dot { width: 8px; height: 8px; border-radius: 50%; background: #059669; }

/* ---- Skeleton Shimmer ---- */
.skeleton {
  background: linear-gradient(90deg, #eee6d6 25%, #f6efdf 37%, #eee6d6 63%);
  background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 12px;
}

/* ---- Toggle Switch ---- */
.tg {
  position: relative; width: 42px; height: 23px;
  border-radius: 99px; background: #2a3140;
  cursor: pointer; border: 0; transition: .2s; flex: none;
}
.tg.on { background: #059669; }
.tg::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; transition: .2s;
}
.tg.on::after { transform: translateX(19px); }

/* ---- Inline Spin Indicator ---- */
.spin {
  display: inline-block; width: 11px; height: 11px;
  border: 2px solid #98a0b0; border-top-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
  margin-right: 6px;
}

/* ---- Hide Utility ---- */
.hide { display: none !important; }

/* ============================================================
   Phase 8 — Micro-interactions (tactile / editorial feel)
   All motion gated behind prefers-reduced-motion.
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  /* Tactile press on every enabled button — the amber pill CTAs
     "give" slightly on click like a physical press. */
  button:not(:disabled):active { transform: scale(.96); }

  /* Editorial nav-link underline: amber thread draws left→right. */
  header.nav nav a {
    position: relative;
  }
  header.nav nav a::after {
    content: ""; position: absolute; left: 0; bottom: -3px;
    width: 100%; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, #D97706, #B45309);
    transform: scaleX(0); transform-origin: left;
    transition: transform .28s cubic-bezier(.22,.61,.36,1);
  }
  header.nav nav a:hover::after,
  header.nav nav a.active::after { transform: scaleX(1); }
}

/* Accessible amber focus ring — keyboard users always see the target. */
a:focus-visible, button:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #D97706; outline-offset: 2px; border-radius: .25rem;
}

/* Editorial trademark: text selection wears the brand amber. */
::selection { background: rgba(217,119,6,.22); color: #2f1500; }

/* Sticky-nav anchor jumps land below the bar with a soft glide. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
}

/* Disabled controls read as inert, not clickable. */
button:disabled, a.pointer-events-none { cursor: not-allowed; }
