/* Hugin — texture & atmosphere utilities (v0.4 mead-hall pass).
   Performance: all effects use either CSS gradients or inline SVG
   feTurbulence baked into a data-uri — no extra HTTP requests, no
   image files. Apply via class + an absolutely-positioned `::before`
   pseudo so the texture sits over the host without affecting layout. */

/* ============================================================
   PARCHMENT — organic grain via SVG feTurbulence noise.
   Use on long-reading panels (transcripts, library cards in expanded
   view, account profile cards). Stays subtle in dark mode, more
   visible in light mode. Multiply blend keeps the host bg intact.
   ============================================================ */
.parchment {
  position: relative;
  isolation: isolate;
}
.parchment::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
  border-radius: inherit;
}
.parchment > * {
  position: relative;
  z-index: 1;
}

/* ============================================================
   VIGNETTE — radial darkening towards the edges. Single warm light
   source at the centre, edges sink into shadow. Use on heroes and
   "intimate" zones (account threshold, library hall view).
   ============================================================ */
.vignette {
  position: relative;
  isolation: isolate;
}
.vignette::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(
    ellipse at center,
    transparent 40%,
    rgba(0, 0, 0, 0.18) 78%,
    rgba(0, 0, 0, 0.42) 100%
  );
  border-radius: inherit;
}

/* Warm vignette — single hearth glow, centred or offset. Pair with
   --bg-hearth panels for the "candle on the table" effect. */
.vignette-warm {
  position: relative;
  isolation: isolate;
}
.vignette-warm::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(
    circle at 50% 30%,
    var(--warm-soft) 0%,
    transparent 45%
  );
  border-radius: inherit;
}

/* ============================================================
   WOOD GRAIN — vertical lines, very subtle, for action surfaces.
   Single linear-gradient + opacity. Performant; no SVG needed.
   Apply to mead-hall panels (transcript header strips, billing card
   bases) where surface should feel like dark stained wood.
   ============================================================ */
.wood {
  background-image:
    linear-gradient(
      90deg,
      transparent 0,
      rgba(0, 0, 0, 0.06) 1px,
      transparent 2px,
      transparent 9px,
      rgba(0, 0, 0, 0.04) 10px,
      transparent 11px,
      transparent 17px,
      rgba(0, 0, 0, 0.06) 18px,
      transparent 19px
    );
  background-size: 19px 100%;
}

/* ============================================================
   HEARTH GLOW — a warm aura around the host element. For audio
   playing indicator, just-completed jobs, hover state on success
   CTAs. Box-shadow only; no extra elements.
   ============================================================ */
.glow-hearth {
  box-shadow:
    0 0 0 1px var(--warm-line),
    0 0 18px var(--warm-soft),
    0 0 42px var(--warm-soft);
}

/* Respect reduced motion + reduced transparency preferences */
@media (prefers-reduced-motion: reduce) {
  .vignette::after,
  .vignette-warm::after { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .parchment::before,
  .vignette::after,
  .vignette-warm::after { opacity: 0.2; }
}
