/* =====================================================================
   Ronelle Perfume — Global storefront infrastructure (Phase 6.5)
   ---------------------------------------------------------------------
   Reusable UX layer consumed by window.RUI (rui-global.js): toasts,
   loading, skeletons, scroll UI, image fade, error states. Token-driven;
   `rui-`-prefixed so the global prefers-reduced-motion rule in
   components.css ([class*=" rui-"]) already calms every animation here.
   Served directly (no Tailwind build). Page layouts are NOT redesigned.
   ===================================================================== */

/* ============================ TOASTS ============================ */
.rui-toaster {
  position: fixed;
  inset-block-start: calc(env(safe-area-inset-top, 0px) + 1rem);
  inset-inline-end: 1rem;
  z-index: var(--rui-z-toast, 1070);
  display: flex;
  flex-direction: column;
  gap: var(--rui-space-xs);
  width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}
.rui-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--rui-space-sm);
  padding: var(--rui-space-sm) var(--rui-space-md);
  border-radius: var(--rui-radius-md);
  background: var(--rui-bg, #fff);
  color: var(--rui-text);
  border: 1px solid var(--rui-border);
  border-inline-start: 3px solid var(--rui-accent);
  box-shadow: var(--rui-shadow-md, 0 10px 30px rgba(0, 0, 0, 0.12));
  font-size: 0.86rem;
  line-height: 1.5;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity var(--rui-duration-base) var(--rui-ease-standard),
              transform var(--rui-duration-base) var(--rui-ease-soft);
}
[dir="rtl"] .rui-toast { transform: translateX(-12px); }
.rui-toast.is-in { opacity: 1; transform: translateX(0); }
.rui-toast.is-out { opacity: 0; transform: translateY(-8px); }

.rui-toast__icon { flex-shrink: 0; display: inline-flex; color: var(--rui-accent); margin-block-start: 1px; }
.rui-toast__msg { flex: 1 1 auto; min-width: 0; }
.rui-toast__action { flex-shrink: 0; align-self: center; padding: .375rem .75rem; border: 0; border-radius: 999px; background: var(--rui-text, #141311); color: var(--rui-bg, #fff); font: 700 .8125rem/1.2 var(--rui-font-text, inherit); white-space: nowrap; cursor: pointer; } /* "View bag" (owner 2026-11-14) */
.rui-toast__action:focus-visible { outline: 2px solid var(--rui-ring, currentColor); outline-offset: 2px; }
.rui-toast__close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--rui-text-subtle);
  cursor: pointer;
  padding: 0;
  line-height: 0;
  transition: color var(--rui-duration-fast) var(--rui-ease-standard);
}
.rui-toast__close:hover { color: var(--rui-text); }

.rui-toast--success { border-inline-start-color: #16a34a; }
.rui-toast--success .rui-toast__icon { color: #16a34a; }
.rui-toast--error   { border-inline-start-color: #dc2626; }
.rui-toast--error   .rui-toast__icon { color: #dc2626; }
.rui-toast--warning { border-inline-start-color: #d97706; }
.rui-toast--warning .rui-toast__icon { color: #d97706; }
.rui-toast--info    { border-inline-start-color: var(--rui-accent); }

@media (max-width: 480px) {
  .rui-toaster { inset-inline: 0.75rem; width: auto; }
}

/* ===================== BACK TO TOP + SCROLL PROGRESS ===================== */
.rui-scrollprog {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  height: 3px;
  z-index: calc(var(--rui-z-header, 1020) + 5);
  background: transparent;
  pointer-events: none;
}
.rui-scrollprog__bar {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: inline-start;
  background: linear-gradient(90deg, var(--rui-accent), var(--rui-accent-hover, var(--rui-accent)));
  transition: transform 80ms linear;
}
[dir="rtl"] .rui-scrollprog__bar { transform-origin: right; }

.rui-totop {
  position: fixed;
  inset-block-end: calc(env(safe-area-inset-bottom, 0px) + 1.25rem + var(--rui-dock-h, 0px)); /* stays above a bottom bar (sticky buy) */
  inset-inline-end: 1.25rem;
  z-index: var(--rui-z-sticky, 1010);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--rui-radius-pill);
  border: 1px solid var(--rui-border);
  background: var(--rui-bg, #fff);
  color: var(--rui-text);
  box-shadow: var(--rui-shadow-md, 0 10px 30px rgba(0, 0, 0, 0.12));
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity var(--rui-duration-base) var(--rui-ease-standard),
              transform var(--rui-duration-base) var(--rui-ease-soft),
              visibility var(--rui-duration-base) var(--rui-ease-standard),
              inset-block-end var(--rui-duration-base) var(--rui-ease-soft);
}
.rui-totop.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.rui-totop:hover { color: var(--rui-accent-strong, var(--rui-accent)); border-color: var(--rui-border-strong); }
.rui-totop:focus-visible { outline: 2px solid var(--rui-accent); outline-offset: 2px; }

/* ============================ LOADING ============================ */
.rui-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: var(--rui-z-overlay, 1030);
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--rui-bg, #fff) 70%, transparent);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--rui-duration-base) var(--rui-ease-standard),
              visibility var(--rui-duration-base) var(--rui-ease-standard);
}
.rui-loading-overlay.is-active { opacity: 1; visibility: visible; }
.rui-loading-overlay--fixed { position: fixed; }

/* ====================== SKELETON COMPOSITIONS ====================== */
/* Built on the existing `.rui-skeleton` shimmer primitive. */
.rui-skel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--rui-space-lg);
}
.rui-skel-card { display: flex; flex-direction: column; gap: var(--rui-space-sm); }
.rui-skel-card__media { aspect-ratio: 3 / 4; border-radius: var(--rui-radius-lg); }
.rui-skel-cart-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: var(--rui-space-sm);
  padding-block: var(--rui-space-md);
  border-block-end: 1px solid var(--rui-border);
}
.rui-skel-cart-item__img { width: 72px; height: 90px; border-radius: var(--rui-radius-md); }
.rui-skel-cart-item__lines { display: flex; flex-direction: column; gap: var(--rui-space-xs); }
.rui-skel-review { display: flex; flex-direction: column; gap: var(--rui-space-xs); padding-block: var(--rui-space-md); }

/* ====================== IMAGE SYSTEM ====================== */
/* JS only adds .rui-img-fade to images that are NOT yet loaded, so cached
   images never flash and a JS failure leaves images fully visible. */
.rui-img-fade { transition: opacity var(--rui-duration-base) var(--rui-ease-standard); }
/* Hidden only while loading; once loaded the image's own opacity applies again (the card's hover photo stays hidden
   until hover — forcing opacity 1 here showed it over the main photo on a first visit, owner 2026-10-26). */
.rui-img-fade:not(.is-loaded) { opacity: 0; }
.rui-img-broken {
  opacity: 1 !important;
  object-fit: contain !important;
  background: var(--rui-surface-sunken, #f4f4f6);
  padding: 12%;
}

/* ====================== ERROR STATE (extends .rui-empty) ====================== */
.rui-empty--error .rui-empty__icon { color: #dc2626; opacity: 1; }
.rui-empty__actions { display: flex; gap: var(--rui-space-sm); justify-content: center; flex-wrap: wrap; margin-block-start: var(--rui-space-sm); }

/* Store scrollbars: thin and quiet, in the neutral ink of the white design */
html{scrollbar-width:thin;scrollbar-color:#c9c9c4 transparent}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{border:3px solid transparent;border-radius:999px;background:#c9c9c4 padding-box}
::-webkit-scrollbar-thumb:hover{background-color:#8f8f8a}

/* Arabic direction review (owner 2026-10-16) ------------------------------------------------------------------
   Typed emails, phone numbers and links read left to right even on Arabic pages (so "+20 10…" keeps its "+" in front
   and "name@mail.com" does not scramble); the Arabic placeholder keeps the page direction until something is typed. */
html[dir="rtl"] :is(input[type="email"], input[type="tel"], input[type="url"], input[inputmode="tel"], input[inputmode="email"], input[autocomplete="username"], input[autocomplete="email"], input[autocomplete="tel"]):not(:placeholder-shown) { direction: ltr; text-align: right; }
/* Star ratings fill from the right in Arabic (half a star sits on the left end). */
html[dir="rtl"] .rn-card-stars { direction: rtl; }
html[dir="rtl"] :is(.rn-card-stars__base, .rn-card-stars__fill) { left: auto; right: 0; }
/* An icon that points "forward" (sign in, continue): mirrored in Arabic. */
html[dir="rtl"] .rui-dir-icon { transform: scaleX(-1); }

/* Line label on cards and the product page (D120): "مجموعة سما" / "SAMA COLLECTION", links to the line page. */
.rui-line-tag { display: inline-block; align-self: flex-start; margin-block-end: .25rem; color: var(--rui-accent-strong, #8a6d12); font-size: .6875rem; letter-spacing: .12em; text-decoration: none; }
html[dir="rtl"] .rui-line-tag { letter-spacing: 0; font-size: .75rem; }
.rui-line-tag:hover { text-decoration: underline; text-underline-offset: 3px; }
.rui-pdp .rui-line-tag, .rui-pdp__buy .rui-line-tag { font-size: .75rem; }

/* Occasion offer strip (owner 2026-11-09): theme setting `offer`, partials/occasion-offer.php */
.rn-occ{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.25rem .6rem;padding:.7rem 1rem;background:var(--occ-bg,#000);color:var(--occ-fg,#fff);text-align:center;font-size:.9rem;line-height:1.35}
.rn-occ b{font-weight:800;letter-spacing:.06em;text-transform:uppercase}
.rn-occ svg{flex:none}
.rn-occ--product,.rn-occ--checkout{border-radius:var(--rui-radius-sm,6px);margin-block:0 1rem}
.rn-occ--product{justify-content:flex-start;text-align:start}
.rcd--page .rn-occ--drawer{grid-column:1/-1;margin:0 0 20px;border-radius:var(--rui-radius-sm,6px)}

/* Pre-order (owner 2026-11-10): product note + bag / checkout tag */
.rn-preorder{margin:0 0 1rem;padding:.7rem .9rem;border:1px solid #e3d7bc;background:#fcfaf5;color:#5b4a26;font-size:.85rem;line-height:1.6;border-radius:var(--rui-radius-sm,6px)}
.rn-preorder[hidden]{display:none}
.rn-pre-tag{display:inline-block;margin-inline-start:.4rem;padding:.05rem .45rem;border-radius:999px;background:#111;color:#fff;font-size:.68rem;font-weight:700;letter-spacing:.02em;vertical-align:middle}
.rui-pc__flag.rui-pc__flag--pre{background:#111;color:#fff}

/* ---------- Product card options (owner 2026-11-14, Maison): photo tint + one button per size ---------- */
[data-theme=ronelle] .rui-pc__media[data-tint][style*="--pc-media-bg"] { background: var(--pc-media-bg); transition: background-color .4s ease; }
/* the name's link is stretched over the whole card: the size buttons sit above it so they get the tap */
[data-theme=ronelle] .rui-pc__sizes { position: relative; z-index: 3; }
[data-theme=ronelle] .rui-pc__sizes { display: grid; grid-template-columns: repeat(auto-fit, minmax(3.5rem, 1fr)); gap: .375rem; margin-block-start: .625rem; }
[data-theme=ronelle] .rui-pc__sizes button { min-height: 2.5rem; padding: 0 .375rem; border: 0; border-radius: 999px; background: var(--rui-surface-sunken, #f3f1ed); color: var(--rui-text, #141311); font: 600 .8125rem/1 var(--rui-font-text, inherit); cursor: pointer; transition: background-color .2s, color .2s, transform .15s; }
[data-theme=ronelle] .rui-pc__sizes button:hover { background: var(--rui-text, #141311); color: var(--rui-bg, #fff); }
[data-theme=ronelle] .rui-pc__sizes button:active { transform: scale(.96); }
[data-theme=ronelle] .rui-pc__sizes button:focus-visible { outline: 2px solid var(--rui-ring, currentColor); outline-offset: 2px; }
[data-theme=ronelle] .rui-pc__sizes button[aria-busy="true"], [data-theme=ronelle] .rui-pc__sizes button:disabled { opacity: .55; cursor: progress; }
@media (prefers-reduced-motion: reduce) { [data-theme=ronelle] .rui-pc__sizes button { transition: none; } }

/* Small shared pieces (owner 2026-11-14): eyebrow with a rule, text link with an arrow (home sections, tool pages) */
.rn-eyebrow{display:flex;align-items:center;gap:.75rem;margin:0 0 .75rem;color:color-mix(in srgb,var(--rn-accent,#c4ab7c) 62%,#000);font-size:.875rem;font-weight:700}
.rn-eyebrow::before{content:"";width:2rem;height:1px;background:currentColor;opacity:.6}
.rn-textlink{display:inline-flex;align-items:center;gap:.4rem;padding-block-end:.2rem;border-block-end:1.5px solid var(--rn-accent,#c4ab7c);color:var(--rui-text,#141311);font-weight:700;font-size:.9375rem;text-decoration:none;white-space:nowrap}
.rn-textlink::after{content:"\2192";transition:transform .25s}[dir=rtl] .rn-textlink::after{content:"\2190"}
.rn-textlink:hover::after{transform:translateX(3px)}[dir=rtl] .rn-textlink:hover::after{transform:translateX(-3px)}
/* our house name inside a perfume name (rn_name_html): its type colour, deepened a little so a light pink reads on white (2026-11-15) */
.rn-house{color:color-mix(in srgb,var(--g,currentColor) 80%,#000)}

/* owner 2026-11-29: the browser's side scrollbar is hidden on the store. The page still scrolls as before (wheel,
   touch, keyboard, trackpad); only the bar is not drawn. Last in the file so it wins over the thin bar above. */
html { scrollbar-width: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; width: 0; height: 0; }
