/*
  The "stone" material: polished black stone with cracks that show the embers glowing through.
  Inspired by the ROREPS membership card. Applied with .card--stone on the "Pentru tine" cards.

  Layers, bottom to top:
    background  stone color + polish reflection (follows the cursor) + stone-grain.svg (mottling, grain, cold cracks)
    ::before    stone-cracks-glow.svg → diffuse red-orange halo around the cracks
    ::after     stone-cracks-core.svg → the glowing filament, orange to white
  The textures are local SVGs in design/assets/, generated by a script (the ember colors live in them, not here:
  they are set as backgrounds, not masks, so they also show when the file is opened directly, where Chrome blocks masks).
  The card stays dark in the light theme too. Loads after sections.css, so it overrides .card.
*/

/* ---------- Stone ---------- */
.card--stone {
  --stone: oklch(0.15 0.006 30);
  --stone-light: oklch(0.22 0.008 30);
  --ember: oklch(0.63 0.22 33);
  --ember-hot: oklch(0.76 0.19 45);
  --halo: 0.8;   /* halo intensity at rest */
  --core: 0.72;  /* glowing filament intensity at rest */
  --rx: 0deg; --ry: 0deg;       /* cursor tilt (see design/assets/js/main.js) */
  --mx: 28%; --my: 18%;         /* reflection position */

  isolation: isolate; overflow: hidden;
  color: var(--n-12);
  border-color: oklch(1 0 0 / 0.1);
  background:
    radial-gradient(70% 60% at var(--mx) var(--my), oklch(1 0 0 / 0.075), transparent 60%),
    url("../stone-grain.svg") center / cover no-repeat,
    radial-gradient(90% 70% at 30% 85%, var(--stone-light), transparent 70%),
    var(--stone);
  box-shadow:
    inset 0 1px 0 oklch(1 0 0 / 0.07),
    inset 1px 0 0 oklch(1 0 0 / 0.03),
    inset 0 -1px 0 oklch(0.63 0.22 33 / 0.35),   /* the bottom edge catches the ember light */
    inset -1px 0 0 oklch(0.63 0.22 33 / 0.12),
    0 24px 60px -28px oklch(0 0 0 / 0.85);
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry));
  transition-property: transform, border-color, box-shadow;
  transition-duration: 700ms, 200ms, 400ms;
  transition-timing-function: var(--ease);
}
.card--stone:hover {
  background-color: var(--stone);   /* skip the background change regular cards get on hover */
  border-color: oklch(1 0 0 / 0.16);
  box-shadow:
    inset 0 1px 0 oklch(1 0 0 / 0.09),
    inset 1px 0 0 oklch(1 0 0 / 0.04),
    inset 0 -1px 0 oklch(0.63 0.22 33 / 0.6),
    inset -1px 0 0 oklch(0.63 0.22 33 / 0.22),
    0 30px 70px -28px oklch(0 0 0 / 0.9),
    0 0 90px -30px oklch(0.6 0.22 33 / 0.55);
  transition-duration: 160ms, 200ms, 400ms; /* follows the cursor closely; eases back slowly */
}

/* The cracks: two layers, halo and filament, so each one's intensity can be animated separately */
.card--stone::before,
.card--stone::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-position: center; background-size: cover; background-repeat: no-repeat;
}
.card--stone::before { background-image: url("../stone-cracks-glow.svg"); opacity: var(--halo); }
.card--stone::after { background-image: url("../stone-cracks-core.svg"); opacity: var(--core); }
.card--stone:hover::before { opacity: 1; }
.card--stone:hover::after { opacity: 1; }
/* Each card gets a different crack pattern from the same texture, mirrored or rotated */
.card--stone:nth-child(2)::before, .card--stone:nth-child(2)::after { transform: scaleX(-1); }
.card--stone:nth-child(3)::before, .card--stone:nth-child(3)::after { transform: rotate(180deg); }

/* Text stays white on stone in both themes; the tag takes the ember color */
.card--stone .card__tag { color: var(--ember-hot); }
.card--stone .card__body { color: var(--n-10); }
.card--stone .card__index { color: var(--n-9); }

/* The embers light up when the card enters the viewport (with data-reveal), then breathe slowly */
@media (prefers-reduced-motion: no-preference) {
  .card--stone::before, .card--stone::after { transition: opacity 1600ms var(--ease) 350ms, filter 300ms var(--ease); }
  .js .card--stone:not(.is-in)::before, .js .card--stone:not(.is-in)::after { opacity: 0; }
  .card--stone.is-in::after { animation: ember 6s ease-in-out 2.2s infinite alternate; }
  .card--stone.is-in::before { animation: ember 6s ease-in-out 3.4s infinite alternate-reverse; }
  .card--stone:hover::before, .card--stone:hover::after { transition-delay: 0ms; transition-duration: 300ms; }
}
@keyframes ember { from { filter: brightness(0.86); } to { filter: brightness(1.18); } }
