/* =========================================================
   Grandma's Stories - textured button kit
   Drop this file + the /textures folder into your app.
   Usage: <a class="tx-btn tx-corduroy" href="#">Start <span class="tx-arrow">-></span></a>
   ========================================================= */

:root {
  --tx-cream: #F6EBD9;
  --tx-espresso: #3A2316;
  --tx-radius-pill: 999px;
  --tx-radius-soft: clamp(14px, 1.6vw, 22px);
}

/* ---------- Base button: stable textured rendering ---------- */
.tx-btn {
  --tex: none;
  --tex-size: 220px;
  --tex-repeat: repeat;
  --tint: transparent;
  --ink: var(--tx-cream);
  --ink-shadow: 0 2px 3px rgba(0, 0, 0, .45);
  --edge: rgba(40, 18, 6, .55);

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  box-sizing: border-box;
  min-height: clamp(56px, 4.5vw + 36px, 96px);
  min-width: 0;
  padding: .4em clamp(1.25em, 3vw, 2em);
  border: 0;
  border-radius: var(--tx-radius-pill);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  text-wrap: balance;
  font-family: "Young Serif", "Cooper Black", Georgia, serif;
  font-size: clamp(1.15rem, 1.4vw + .8rem, 2rem);
  line-height: 1.1;
  color: var(--ink);
  text-shadow: var(--ink-shadow);
  background:
    linear-gradient(var(--tint), var(--tint)),
    var(--tex) center / var(--tex-size) var(--tex-repeat);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .22),
    inset 0 -4px 0 rgba(0, 0, 0, .22),
    inset 0 0 0 1.5px var(--edge),
    0 2px 0 rgba(0, 0, 0, .25),
    0 10px 22px rgba(40, 18, 6, .45);
  /* Do not transform or promote textured controls to GPU layers:
     Safari can drop/repaint layered background images during hover. */
  transition: color 160ms ease, outline-color 160ms ease, border-color 160ms ease;
  -webkit-tap-highlight-color: rgba(242, 193, 78, .18);
}
.tx-btn:hover {
  color: #fff;
  outline: 2px solid rgba(246, 235, 217, .62);
  outline-offset: 3px;
}
.tx-btn:active {
  color: #fff0d8;
  outline: 2px solid rgba(242, 193, 78, .9);
  outline-offset: 1px;
}
.tx-btn:focus-visible { outline: 3px solid #F2C14E; outline-offset: 4px; }
.tx-btn:disabled,
.tx-btn[aria-disabled="true"] {
  cursor: not-allowed;
  filter: none;
}
.tx-soft { border-radius: var(--tx-radius-soft); }
.tx-arrow {
  font-family: system-ui, sans-serif;
  font-weight: 600;
  display: inline-block;
}
.tx-icon { width: 1.3em; height: 1.3em; flex: none; }

/* ---------- Texture variants ----------
 ----------
   image-set serves the 512px tile to standard screens and the 1024px tile to retina. */
.tx-corduroy {
  --tex: image-set(url("corduroy-512.webp") 1x, url("corduroy.webp") 2x);
  --tex-size: 140px;
  --edge: rgba(90, 30, 8, .7);
}
.tx-shag {
  --tex: image-set(url("shag-512.webp") 1x, url("shag.webp") 2x);
  --tex-size: 260px;
  --tint: rgba(60, 25, 8, .28);
  --ink-shadow: 0 2px 4px rgba(0, 0, 0, .75);
}
.tx-walnut {
  --tex: image-set(url("walnut-512.webp") 1x, url("walnut.webp") 2x);
  --tex-size: 520px;
  --tex-repeat: repeat-x;
  --edge: rgba(20, 8, 2, .75);
}
.tx-tweed {
  --tex: image-set(url("tweed-512.webp") 1x, url("tweed.webp") 2x);
  --tex-size: 240px;
  --tint: rgba(30, 30, 10, .12);
  --ink-shadow: 0 2px 3px rgba(0, 0, 0, .7);
}
.tx-floral {
  --tex: image-set(url("floral-512.webp") 1x, url("floral.webp") 2x);
  --tex-size: cover;
  --tex-repeat: no-repeat;
  --tint: rgba(246, 235, 217, .35);
  --ink: var(--tx-espresso);
  --ink-shadow: 0 1px 0 rgba(255, 248, 235, .9), 0 0 12px rgba(255, 248, 235, .9);
  --edge: rgba(120, 60, 20, .5);
}
.tx-leather {
  --tex: image-set(url("leather-512.webp") 1x, url("leather.webp") 2x);
  --tex-size: 360px;
  --edge: rgba(60, 25, 8, .75);
}
.tx-knit {
  --tex: image-set(url("knit-512.webp") 1x, url("knit.webp") 2x);
  --tex-size: 240px;
  --ink: var(--tx-espresso);
  --ink-shadow: 0 1px 0 rgba(255, 255, 255, .6);
  --edge: rgba(120, 95, 60, .45);
}
.tx-linen {
  --tex: image-set(url("linen-512.webp") 1x, url("linen.webp") 2x);
  --tex-size: 320px;
  --ink: var(--tx-espresso);
  --ink-shadow: 0 1px 0 rgba(255, 255, 255, .55);
  --edge: rgba(120, 95, 60, .4);
}

/* ---------- Respect user preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .tx-btn, .tx-arrow { transition: none; }
  .tx-btn:hover { transform: none; }
}
