/* ==========================================================================
   Gilora preloader — markup: resources/views/partials/loader.blade.php
   html.gl-intro  first page of the session: the mark draws itself.
   html.gl-quick  later pages: the finished mark, shown only if loading is slow.
   html.gl-loading set by loader.js while the overlay is up (scroll lock).
   ========================================================================== */
html.gl-loading { overflow: hidden; }

.gl-loader {
  --forest: #1E5E2F;
  --saffron: #EA6C14;
  --leaf: #8AAB3A;
  --gold: #C9A961;
  --cream: #FBF8EF;
  --cx: 50%;
  --cy: 42%;
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #1B2A1F;
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: radial-gradient(60% 55% at 50% 42%, #FFFDF6 0%, var(--cream) 55%, #F1E9D2 100%);
  clip-path: circle(150% at var(--cx) var(--cy));
  transition: clip-path .85s cubic-bezier(.7, 0, .2, 1);
  /* Failsafe: never trap the page if loader.js does not run. */
  animation: gl-failsafe .4s 12s forwards;
}
.gl-loader.is-leaving { clip-path: circle(0% at var(--cx) var(--cy)); pointer-events: none; }
.gl-loader.is-leaving .gl-loader__stage { opacity: 0; transform: scale(.9); }
html.gl-quick .gl-loader { opacity: 0; animation: gl-fade-in .3s .35s forwards, gl-failsafe .4s 12s forwards; }
.gl-sr { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- ambient particles ---------- */
.gl-loader__air { position: absolute; inset: 0; pointer-events: none; }
.gl-particle {
  position: absolute;
  bottom: -60px;
  left: var(--x);
  width: calc(34px * var(--s));
  height: calc(34px * var(--s));
  opacity: 0;
  animation: gl-float var(--t) linear var(--d) infinite;
}

/* ---------- stage ---------- */
.gl-loader__stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  text-align: center;
  perspective: 900px;
  transition: opacity .45s, transform .6s cubic-bezier(.7, 0, .2, 1);
}

.gl-mark-wrap {
  position: relative;
  width: clamp(170px, 40vmin, 260px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform .25s ease-out;
  -webkit-tap-highlight-color: transparent;
}
.gl-mark-wrap::before {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(255, 255, 255, .85) 45%, rgba(255, 255, 255, 0) 72%);
  box-shadow: 0 30px 60px -35px rgba(30, 94, 47, .45);
}
.gl-mark-wrap:focus-visible { outline: 2px dashed var(--gold); outline-offset: 8px; }
.gl-mark-wrap:active .gl-mark { transform: scale(.96); }

.gl-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.gl-ring circle { fill: none; }
.gl-ring__track { stroke: #EFE7CF; stroke-width: 1.5; }
.gl-ring__dots {
  stroke: #D4B978;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 0 12.06;
  opacity: .55;
  transform-origin: center;
  animation: gl-spin 40s linear infinite;
}
.gl-ring__bar {
  stroke: var(--forest);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .35s ease-out;
}

.gl-mark { position: absolute; inset: 9%; width: 82%; height: 82%; overflow: visible; transition: transform .2s; }
.gl-arc, .gl-bowl { fill: var(--forest); }
.gl-wave { fill: var(--saffron); }
.gl-leaf path { fill: var(--leaf); }
.gl-leaf path.gl-leaf__vein { fill: #FFFDF6; }

/* Shape reveal masks: a fat stroke drawn along each shape's centre line. */
.gl-draw { fill: none; stroke: #fff; stroke-dasharray: 1 1; stroke-dashoffset: 0; }
.gl-draw--arc { stroke-width: 110; }
.gl-draw--wave { stroke-width: 140; }
.gl-draw--bowl { stroke-width: 210; }

/* Parallax layers follow --px/--py (-1…1) set from the pointer. */
.gl-depth {
  transform: translate(calc(var(--px, 0) * var(--z) * 40px), calc(var(--py, 0) * var(--z) * 40px));
  transition: transform .3s ease-out;
}

.gl-leaf {
  transform-box: view-box;
  transform-origin: 568px 1003px;
  animation: gl-sway 4.5s ease-in-out infinite;
}

.gl-steam { transform-box: view-box; transform-origin: 855px 600px; transition: transform .6s cubic-bezier(.34, 1.56, .64, 1); }
.gl-steam path {
  fill: none;
  stroke: var(--saffron);
  stroke-width: 22;
  stroke-linecap: round;
  stroke-dasharray: 1 1;
  animation: gl-steam 2.6s ease-in-out infinite both;
  transition: stroke-width .4s;
}
.gl-steam path + path { animation-delay: .7s; }

.gl-rice ellipse { fill: #fff; stroke: #D4B978; stroke-width: 5; opacity: 0; transform-box: fill-box; transform-origin: center; }
.gl-oil__drop { opacity: 0; transform-box: view-box; transform-origin: 830px 718px; }
.gl-oil__ripple { fill: none; stroke: #E3B23C; stroke-width: 5; opacity: 0; transform-box: fill-box; transform-origin: center; }
.gl-sheen { opacity: 0; }

/* ---------- category reactions ---------- */
.gl-loader[data-cat="tea"] .gl-steam { transform: scale(1.22); }
.gl-loader[data-cat="tea"] .gl-steam path { stroke-width: 28; }
.gl-loader[data-cat="tea"] .gl-leaf { animation: gl-wiggle 1s ease-in-out, gl-sway 4.5s 1s ease-in-out infinite; }

.gl-loader[data-cat="rice"] .gl-rice ellipse { animation: gl-fall 1.15s var(--d) cubic-bezier(.55, 0, .85, .45) both; }

.gl-loader[data-cat="oil"] .gl-oil__drop { animation: gl-drop 1.5s cubic-bezier(.5, 0, .75, 0) both; }
.gl-loader[data-cat="oil"] .gl-oil__ripple { animation: gl-ripple 1.5s ease-out both; }
.gl-loader[data-cat="oil"] .gl-sheen { animation: gl-sheen 1.3s ease-in-out both; }

/* ---------- wordmark, categories, caption ---------- */
.gl-word strong {
  display: block;
  font-family: Kahroba, Vazirmatn, serif;
  font-size: clamp(2rem, 6vmin, 2.75rem);
  font-weight: 800;
  line-height: 1.15;
  color: var(--forest);
}
.gl-word span {
  display: block;
  margin-top: .15rem;
  direction: ltr;
  font-size: .7rem;
  letter-spacing: .45em;
  text-transform: uppercase;
  color: #B8934A;
}

.gl-cats { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; max-width: 30rem; }
.gl-cat {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .95rem;
  border: 1px solid #E3D7B5;
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
  color: #4A5A4E;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: background-color .35s, border-color .35s, color .35s, box-shadow .35s, transform .35s cubic-bezier(.34, 1.56, .64, 1);
}
.gl-cat svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: stroke .35s, transform .5s cubic-bezier(.34, 1.56, .64, 1); }
.gl-cat:hover { border-color: var(--gold); transform: translateY(-2px); }
.gl-cat:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.gl-cat.is-active { background: var(--forest); border-color: var(--forest); color: #fff; box-shadow: 0 10px 22px -12px rgba(30, 94, 47, .8); }
.gl-cat.is-active svg { transform: rotate(-12deg) scale(1.15); }
.gl-cat[data-gl-cat="tea"].is-active svg { stroke: #F5A468; }
.gl-cat[data-gl-cat="rice"].is-active svg { stroke: #EDE2C4; }
.gl-cat[data-gl-cat="oil"].is-active svg { stroke: #E3B23C; }

.gl-tip { min-height: 1.6em; margin: 0; font-size: .85rem; color: #75837A; }
.gl-tip [data-gl-tip] { display: inline-block; transition: opacity .3s, transform .3s; }
.gl-tip [data-gl-tip].is-swapping { opacity: 0; transform: translateY(6px); }
.gl-tip b { margin-inline-start: .35rem; font-weight: 700; color: var(--forest); font-variant-numeric: tabular-nums; }

.gl-skip {
  position: absolute;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  left: 50%;
  translate: -50% 0;
  padding: .35rem .75rem;
  border: 0;
  background: none;
  color: #75837A;
  font: inherit;
  font-size: .78rem;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  opacity: 0;
  animation: gl-fade-in .4s 3s forwards;
}
.gl-skip:hover, .gl-skip:focus-visible { color: var(--forest); }

/* ---------- first-visit intro choreography ---------- */
@media (prefers-reduced-motion: no-preference) {
  html.gl-intro .gl-draw { stroke-dashoffset: 1; animation: gl-draw var(--t) var(--d) cubic-bezier(.65, 0, .35, 1) forwards; }
  html.gl-intro .gl-draw--arc { --t: 1s; --d: .15s; }
  html.gl-intro .gl-draw--wave { --t: .9s; --d: .6s; }
  html.gl-intro .gl-draw--bowl { --t: 1s; --d: .85s; }
  html.gl-intro .gl-leaf { animation: gl-leaf-in .9s 1.45s cubic-bezier(.34, 1.56, .64, 1) both, gl-sway 4.5s 2.4s ease-in-out infinite; }
  html.gl-intro .gl-steam path { animation-delay: 1.8s; }
  html.gl-intro .gl-steam path + path { animation-delay: 2.4s; }
  html.gl-intro .gl-ring { animation: gl-ring-in 1s .1s cubic-bezier(.34, 1.56, .64, 1) both; }
  html.gl-intro .gl-word strong { animation: gl-reveal .9s 1.3s cubic-bezier(.65, 0, .35, 1) both; }
  html.gl-intro .gl-word span { animation: gl-track 1s 1.6s ease-out both; }
  html.gl-intro .gl-cat, html.gl-intro .gl-tip { animation: gl-rise .6s cubic-bezier(.34, 1.56, .64, 1) both; }
  html.gl-intro .gl-cat:nth-child(1) { animation-delay: 1.75s; }
  html.gl-intro .gl-cat:nth-child(2) { animation-delay: 1.85s; }
  html.gl-intro .gl-cat:nth-child(3) { animation-delay: 1.95s; }
  html.gl-intro .gl-tip { animation-delay: 2.1s; }
}

@media (prefers-reduced-motion: reduce) {
  .gl-loader, .gl-loader *, .gl-loader *::before { animation: none !important; transition: none !important; }
  .gl-loader__air { display: none; }
  .gl-steam path { stroke-dashoffset: 0; }
  .gl-skip { opacity: 1; }
  html.gl-quick .gl-loader { opacity: 1; }
}

@media print { .gl-loader { display: none; } }

/* ---------- keyframes ---------- */
@keyframes gl-draw { to { stroke-dashoffset: 0; } }
@keyframes gl-fade-in { to { opacity: 1; } }
@keyframes gl-failsafe { to { opacity: 0; visibility: hidden; } }
@keyframes gl-spin { to { transform: rotate(360deg); } }
@keyframes gl-ring-in { from { opacity: 0; transform: rotate(-200deg) scale(.7); } }
@keyframes gl-reveal { from { clip-path: inset(0 0 0 100%); opacity: .3; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
@keyframes gl-track { from { opacity: 0; letter-spacing: 1.1em; } }
@keyframes gl-rise { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes gl-leaf-in { from { transform: scale(0) rotate(-35deg); } to { transform: scale(1) rotate(0); } }
@keyframes gl-sway { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-4deg); } }
@keyframes gl-wiggle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-12deg) scale(1.05); }
  45% { transform: rotate(7deg); }
  70% { transform: rotate(-4deg); }
}
@keyframes gl-steam {
  0% { stroke-dashoffset: 1; opacity: 0; transform: translateY(30px); }
  20% { opacity: 1; }
  55% { stroke-dashoffset: 0; }
  80% { opacity: .8; }
  100% { stroke-dashoffset: -1; opacity: 0; transform: translateY(-50px); }
}
@keyframes gl-fall {
  0% { opacity: 0; transform: translateY(-90px) rotate(var(--r)); }
  15% { opacity: 1; }
  82% { opacity: 1; transform: translateY(610px) rotate(calc(var(--r) * -1 + 90deg)); }
  100% { opacity: 0; transform: translateY(650px) rotate(calc(var(--r) * -1 + 90deg)) scale(.6); }
}
@keyframes gl-drop {
  0% { opacity: 0; transform: scale(0); }
  30% { opacity: 1; transform: scale(1); }
  42% { transform: scale(.88, 1.15); }
  84% { opacity: 1; transform: translateY(100px) scale(.85, 1.12); }
  90%, 100% { opacity: 0; transform: translateY(110px) scale(1.4, .35); }
}
@keyframes gl-ripple {
  0%, 84% { opacity: 0; transform: scale(.2); }
  88% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.7); }
}
@keyframes gl-sheen {
  0% { opacity: 1; transform: translateX(0); }
  100% { opacity: 1; transform: translateX(1100px); }
}
@keyframes gl-float {
  0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(0); }
  12% { opacity: .35; }
  50% { transform: translate3d(30px, -55vh, 0) rotate(160deg); }
  88% { opacity: .35; }
  100% { opacity: 0; transform: translate3d(-20px, -115vh, 0) rotate(320deg); }
}
