/* --------------------------------------------------------------------------
   Enchantment layer
   --------------------------------------------------------------------------
   Loaded on every HTML page by App\Http\Middleware\PageMotion (see
   resources/views/motion.blade.php), so it works on layout pages and on the
   standalone pages that ship their own <html>.

   The head script in motion.blade.php stamps these classes on <html>:
     kob-enchant    the layer is active (always, unless reduced motion)
     kob-sparkles   wand cursor + sparkle trail (visitor can switch it off)
     kob-calm-page  a game page: no trail, no reveals, no cursor

   Page authors can use:
     data-reveal          fade an element up when it scrolls into view
     data-reveal="off"    never auto-reveal this element or its children
     data-glint           a slow gold light sweep across the element on hover
     .kob-shimmer-text    a gold shimmer that runs across gradient-free text
   -------------------------------------------------------------------------- */

:root {
  --kob-cursor-wand: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M8 8L28.5 28.5' stroke='%23fff6dc' stroke-width='5.4' stroke-linecap='round'/%3E%3Cpath d='M8 8L28.5 28.5' stroke='%232a1810' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M19.5 19.5L28.5 28.5' stroke='%235b3a22' stroke-width='3.6' stroke-linecap='round'/%3E%3Cpath d='M18.6 20.4L20.4 18.6' stroke='%23e2b33c' stroke-width='1.6' stroke-linecap='round'/%3E%3Cpath d='M5 1L6.28 3.7199999999999998L9 5L6.28 6.28L5 9L3.7199999999999998 6.28L1 5L3.7199999999999998 3.7199999999999998Z' fill='%23ffd84a' stroke='%237a4b00' stroke-width='0.8' stroke-linejoin='round'/%3E%3C/svg%3E") 5 5, auto;
  --kob-cursor-wand-lit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Ccircle cx='5' cy='5' r='5' fill='%23ffd76a' opacity='0.4'/%3E%3Cpath d='M7 7L19 19' stroke='%23fff6dc' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M19 19L31 24L30 27.5L27.5 30L24 31Z' fill='%23fff6dc' stroke='%23fff6dc' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M7 7L19 19' stroke='%236b4423' stroke-width='2.8' stroke-linecap='round'/%3E%3Cpath d='M19 19L31 24L30 27.5L27.5 30L24 31Z' fill='%23d9a423' stroke='%238a5a00' stroke-width='0.9' stroke-linejoin='round'/%3E%3Cpath d='M19.5 19.5L30 23' stroke='%238a5a00' stroke-width='0.7'/%3E%3Cpath d='M19.5 19.5L29 26.5' stroke='%238a5a00' stroke-width='0.7'/%3E%3Cpath d='M19.5 19.5L26.5 29' stroke='%238a5a00' stroke-width='0.7'/%3E%3Cpath d='M19.5 19.5L23 30' stroke='%238a5a00' stroke-width='0.7'/%3E%3Cpath d='M19.5 19.5L28 28' stroke='%238a5a00' stroke-width='0.7'/%3E%3Cpath d='M17.6 20.4L20.4 17.6' stroke='%235b3a22' stroke-width='2.2' stroke-linecap='round'/%3E%3Cpath d='M5 0L6.6 3.4L10 5L6.6 6.6L5 10L3.4 6.6L0 5L3.4 3.4Z' fill='%23fff1b0' stroke='%237a4b00' stroke-width='0.8' stroke-linejoin='round'/%3E%3C/svg%3E") 5 5, pointer;
  --kob-ease-spell: cubic-bezier(.2, .9, .25, 1.15);
  --kob-ease-soft: cubic-bezier(.16, .84, .32, 1);
}

/* Wand cursor, and a broom over anything clickable. `cursor` is inherited,
   so setting it on <html> covers every element that has not chosen its own
   cursor. The broom and text rules sit at zero specificity, so any page rule
   still wins. */
@media (pointer: fine) {
  html.kob-sparkles:not(.kob-calm-page) {
    cursor: var(--kob-cursor-wand);
  }

  html.kob-sparkles:not(.kob-calm-page) :where(a[href], button:not(:disabled), summary, select, label[for],
    [role="button"], [role="tab"], [role="link"], input[type="submit"], input[type="button"],
    input[type="checkbox"], input[type="radio"], input[type="file"], input[type="color"], [onclick],
    .card, .choice, .btn, .btn-magic, .clickable, [style*="cursor: pointer"], [style*="cursor:pointer"]) {
    cursor: var(--kob-cursor-wand-lit);
  }

  html.kob-sparkles:not(.kob-calm-page) :where(input:not([type]), input[type="text"], input[type="email"],
    input[type="password"], input[type="search"], input[type="url"], input[type="tel"],
    input[type="number"], textarea, [contenteditable="true"]) {
    cursor: text;
  }
}

/* Selection, focus and scrollbars ---------------------------------------- */

html.kob-enchant ::selection {
  background: rgba(var(--kob-gold-rgb, 255, 215, 0), 0.35);
  color: inherit;
}

html.kob-enchant :where(a, button, summary, input, select, textarea, [tabindex], [role="button"]):focus-visible {
  outline: 2px solid var(--kob-gold, #ffd700);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(var(--kob-gold-rgb, 255, 215, 0), 0.18), 0 0 22px rgba(var(--kob-gold-rgb, 255, 215, 0), 0.35);
  transition: outline-offset .25s var(--kob-ease-spell), box-shadow .25s ease;
}

@supports (scrollbar-color: red blue) {
  html.kob-enchant {
    scrollbar-color: rgba(var(--kob-gold-rgb, 255, 215, 0), 0.45) rgba(var(--kob-deep-rgb, 10, 0, 26), 0.9);
  }
}

/* Scroll reveal ---------------------------------------------------------- */

html.kob-enchant .kob-reveal {
  opacity: 0;
  translate: 0 26px;
  scale: 0.985;
  transition:
    opacity .75s var(--kob-ease-soft) var(--kob-reveal-delay, 0ms),
    translate .9s var(--kob-ease-soft) var(--kob-reveal-delay, 0ms),
    scale .9s var(--kob-ease-soft) var(--kob-reveal-delay, 0ms);
}

html.kob-enchant .kob-reveal.kob-revealed {
  opacity: 1;
  translate: 0 0;
  scale: 1;
}

/* Glint: a light sweep across cards and buttons on hover ----------------- */

html.kob-enchant [data-glint] {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

html.kob-enchant [data-glint]::after {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 240, 200, 0.28) 47%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 240, 200, 0.28) 53%, transparent 62%);
  translate: -120% 0;
  transition: translate 0s;
}

html.light.kob-enchant [data-glint]::after {
  background: linear-gradient(105deg, transparent 38%, rgba(255, 236, 170, 0.35) 47%, rgba(255, 255, 255, 0.7) 50%, rgba(255, 236, 170, 0.35) 53%, transparent 62%);
}

html.kob-enchant [data-glint]:hover::after,
html.kob-enchant [data-glint]:focus-visible::after {
  translate: 120% 0;
  transition: translate 1s var(--kob-ease-soft);
}

/* Shimmer text ----------------------------------------------------------- */

html.kob-enchant .kob-shimmer-text {
  background: linear-gradient(100deg, var(--kob-title-bottom) 0%, var(--kob-title-mid) 30%, #fff6d0 48%, var(--kob-title-mid) 62%, var(--kob-title-bottom) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: kob-shimmer 7s ease-in-out infinite;
}

html.light.kob-enchant .kob-shimmer-text {
  background-image: linear-gradient(100deg, var(--kob-title-bottom) 0%, var(--kob-title-mid) 30%, #e8b93a 48%, var(--kob-title-mid) 62%, var(--kob-title-bottom) 100%);
}

@keyframes kob-shimmer {
  0%, 15% { background-position: 100% 0; }
  60%, 100% { background-position: 0% 0; }
}

/* Scroll ribbon ---------------------------------------------------------- */

.kob-ribbon {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 99991;
  pointer-events: none;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, rgba(var(--kob-accent-soft-rgb, 200, 182, 255), 0.2), var(--kob-gold, #ffd700) 70%, #fff6d0);
  box-shadow: 0 0 10px rgba(var(--kob-gold-rgb, 255, 215, 0), 0.7);
  opacity: 0;
  transition: opacity .4s ease;
}

.kob-ribbon.is-on { opacity: 1; }

/* Sparkle canvas --------------------------------------------------------- */

.kob-sparkle-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99990;
  pointer-events: none;
}

/* Spell toast (Lumos / Nox / Accio) -------------------------------------- */

.kob-spell-toast {
  position: fixed;
  left: 50%;
  bottom: 12vh;
  z-index: 99992;
  pointer-events: none;
  translate: -50% 0;
  padding: 14px 30px 12px;
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 18px;
  background: rgba(14, 6, 32, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 240, 200, 0.12);
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: clamp(22px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #ffd76a;
  text-shadow: 0 0 18px rgba(255, 215, 0, 0.7), 0 2px 0 rgba(0, 0, 0, 0.35);
  animation: kob-spell-toast 1.8s var(--kob-ease-soft) forwards;
}

.kob-spell-toast small {
  display: block;
  margin-top: 6px;
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  text-align: center;
  color: #d9c8ff;
  text-shadow: none;
}

@keyframes kob-spell-toast {
  0% { opacity: 0; scale: 0.8; filter: blur(6px); }
  18% { opacity: 1; scale: 1.04; filter: blur(0); }
  30% { scale: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; translate: -50% -18px; }
}

/* Sparkles switch -------------------------------------------------------- */

.kob-wand-switch {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 99989;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(var(--kob-gold-rgb, 255, 215, 0), 0.45);
  background: rgba(var(--kob-deep-rgb, 10, 0, 26), 0.78);
  color: var(--kob-gold, #ffd700);
  font-size: 17px;
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(var(--kob-shadow-rgb, 0, 0, 0), 0.3);
  opacity: 0.6;
  transition: opacity .25s ease, transform .35s var(--kob-ease-spell), box-shadow .3s ease;
}

.kob-wand-switch:hover,
.kob-wand-switch:focus-visible {
  opacity: 1;
  transform: rotate(-14deg) scale(1.08);
  box-shadow: 0 0 0 4px rgba(var(--kob-gold-rgb, 255, 215, 0), 0.12), 0 0 24px rgba(var(--kob-gold-rgb, 255, 215, 0), 0.4);
}

/* Touch screens get no trail, only brief tap bursts; keep the corner clear. */
@media (pointer: coarse) {
  .kob-wand-switch { display: none; }
}

.kob-wand-switch[aria-pressed="false"] {
  color: var(--kob-ink-muted, #a89cc8);
  border-color: rgba(var(--kob-veil-rgb, 255, 255, 255), 0.2);
}

.kob-wand-switch[aria-pressed="false"] span {
  opacity: 0.55;
  filter: grayscale(1);
}

/* Theme flip (View Transitions) ----------------------------------------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

@media print {
  .kob-ribbon,
  .kob-sparkle-canvas,
  .kob-wand-switch,
  .kob-spell-toast { display: none !important; }
  html.kob-enchant .kob-reveal { opacity: 1 !important; translate: none !important; scale: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  html.kob-enchant .kob-reveal { opacity: 1; translate: none; scale: none; transition: none; }
  html.kob-enchant [data-glint]::after { display: none; }
  html.kob-enchant .kob-shimmer-text { animation: none; background-position: 50% 0; }
}
