/* ================= Tactile layer: how Luneia surfaces answer to a pointer, a finger or a key =================
   Shared and opt-in. Add class "tx" to any button or card (and "tx-icon" to small round icon buttons).
   Used first on /links/. To extend it to another page: add "tactile" to that page's css list in its <!--meta-->,
   and put the classes on the elements. Remove any older transform-based hover on those elements (it would add to this one).

   One feel, three states:
   - hover (mouse only):  rises 2px, border and surface warm up (the cursor light from fx.js already follows the pointer)
   - press (mouse+touch): sinks a little, surface goes one step lighter
   - keyboard focus:      same lift as hover plus a ring that follows the element's own shape
   Motion uses the individual `translate` and `scale` properties, so it never fights the scroll-reveal
   (which owns `transform`) and the hover has no stagger delay. All movement is off for reduced motion; the
   colour changes stay. */

:root {
  --tx-lift: -3px;          /* hover rise */
  --tx-press: .955;         /* press scale: wide pills and rows */
  --tx-press-card: .94;    /* press scale: square-ish cards */
  --tx-press-icon: .85;      /* press scale: small round icon buttons */
  --tx-ring: color-mix(in srgb, var(--moon) 70%, transparent);
}

.tx, .tx-icon {
  position: relative; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  /* order: opacity, transform (the reveal) | translate, scale, background-color, border-color, color, box-shadow (the touch) */
  transition-property: opacity, transform, translate, scale, background-color, border-color, color, box-shadow;
  transition-duration: var(--t-reveal), var(--t-reveal), var(--t-base), 140ms, var(--t-base), var(--t-base), var(--t-base), var(--t-base);
  transition-timing-function: var(--ease-out);
  /* stagger belongs to the reveal only; hover never waits */
  transition-delay: calc(var(--i, 0) * 70ms), calc(var(--i, 0) * 70ms), 0s, 0s, 0s, 0s, 0s, 0s;
}

/* Invisible 3px skirt above and below: the lift never moves the element out from under a pointer resting on its edge. */
.tx { isolation: isolate; }
.tx::after { content: ""; position: absolute; inset: -3px 0; border-radius: inherit; }

/* A soft band of light that crosses the surface once on hover (not for reduced motion) */
.tx::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 1; opacity: 0;
  background: linear-gradient(105deg, transparent 20%, rgba(255, 244, 225, .06) 50%, transparent 80%) no-repeat; background-size: 300% 100%; background-position: 140% 0; }
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .tx:hover::before { opacity: 1; background-position: -40% 0; transition: background-position 2.2s var(--ease-in-out), opacity .6s; }
}

/* Colour answers (no movement): safe for everyone */
@media (hover: hover) and (pointer: fine) {
  .tx:hover { background-color: var(--hover); border-color: color-mix(in srgb, var(--moon) 45%, transparent); box-shadow: 0 1px 0 rgba(255, 250, 240, .06) inset, 0 22px 34px -20px rgba(0, 0, 0, .95), 0 0 0 1px color-mix(in srgb, var(--moon) 12%, transparent), 0 0 28px -8px color-mix(in srgb, var(--moon) 28%, transparent); }
}
.tx:active { background-color: var(--hover); border-color: var(--hover-line); }

/* Keyboard: ring that follows each element's own shape */
.tx:focus-visible, .tx-icon:focus-visible { outline: 2px solid var(--tx-ring); outline-offset: 3px; }
.tx:focus-visible { background-color: var(--hover); border-color: var(--hover-line); }

/* Movement */
@media (prefers-reduced-motion: no-preference) {
  @media (hover: hover) and (pointer: fine) {
    .tx:hover, .tx:focus-visible { translate: 0 var(--tx-lift); scale: 1.015; }
    .tx-icon:hover, .tx-icon:focus-visible { translate: 0 var(--tx-lift); }
    .tx-icon:hover { box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .8); }
  }
  .tx:active, .tx-icon:active { scale: var(--tx-press); translate: 0 0; transition-duration: var(--t-reveal), var(--t-reveal), 90ms, 90ms, 90ms, 90ms, 90ms, 90ms; }
  .tx-card:active { scale: var(--tx-press-card); }
  .tx-icon:active { scale: var(--tx-press-icon); }
  /* on release the scale springs back with a touch of overshoot; everything else just eases */
  .tx:not(:active), .tx-icon:not(:active) { transition-timing-function: var(--ease-out), var(--ease-out), var(--ease-out), var(--ease-spring), var(--ease-out), var(--ease-out), var(--ease-out), var(--ease-out); }

  /* The small things inside move a little with the element */
  .tx .tx-ico { transition: transform .5s var(--ease-spring); }
  .tx-go { transition: transform var(--t-base) var(--ease-out), color var(--t-base), background-color var(--t-base); }
  @media (hover: hover) and (pointer: fine) {
    .tx:hover .tx-ico, .tx:focus-visible .tx-ico { transform: scale(1.16) rotate(-7deg); }
    .tx:hover .tx-go, .tx:focus-visible .tx-go { transform: translateX(6px); }
    .tx[target="_blank"]:hover .tx-go, .tx[target="_blank"]:focus-visible .tx-go { transform: translate(4px, -4px); }
  }
  .tx:active .tx-ico { transform: scale(.86); transition-duration: 90ms; }
}

/* The blog picture settles slowly on hover; none of that for reduced motion */
@media (prefers-reduced-motion: reduce) { .lk-post__img img { transition: none; transform: none !important; } }

/* Forms: a field that is being typed in lights up its own edge (the old focus line was invisible on /links/) */
.tx-field { transition: border-color var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out), background-color var(--t-base); }
.tx-field:focus { outline: 0; border-color: var(--moon); box-shadow: 0 0 0 3px color-mix(in srgb, var(--moon) 16%, transparent); }
@media (hover: hover) and (pointer: fine) { .tx-field:hover:not(:focus) { border-color: var(--text-3); } }

/* Submit buttons: while sending, quiet and "busy"; when done, one soft light pulse on the form */
.btn[disabled] { cursor: progress; opacity: .72; }
@media (prefers-reduced-motion: no-preference) {
  form.is-sent { animation: tx-sent .9s var(--ease-out); }
  @keyframes tx-sent { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--moon) 45%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
}
