/* metal-surface.css — anisotropic metal from one conic gradient.
 *
 * After CodePen thebabydino/VeBoXx (Ana Tudor), "pure CSS metallic buttons with
 * shadow (no pseudos)". The mechanism, the presets and the don'ts live in
 * techniques/metal-surface.md; this is the shippable part.
 *
 * ⭐ THREE BACKGROUNDS, THREE CLIP BOXES, ONE ELEMENT. A transparent border
 * opens a ring outside the padding box, and the cast shadow is painted there —
 * which is why this needs no ::before and no wrapper. Anything that wants a
 * shaped shadow can borrow that trick on its own.
 *
 * Usage — the element supplies its own size and radius; the part supplies the
 * material only:
 *
 *   <div class="metal metal--silver"></div>
 *   <div class="metal metal--gold"></div>
 *   <div class="metal metal--bronze"></div>
 *   <div class="metal metal--titanium"></div>
 *
 * ⚠ NOT FOR BUTTONS, despite the source. A control that looks like polished
 * metal reads as a skeuomorphic toy and fights every other control. Use it on
 * an OBJECT — a badge, a seal, a plate — never on an affordance.
 * ⚠ NOTHING READABLE ON TOP. The sheen crosses light and dark within a few
 * pixels, so no fixed text colour clears 4.5:1 across it.
 */

.metal{
  /* the ring the cast shadow is painted into; 0 turns the shadow off */
  --metal-lift: 0.625em;
  --metal-rim: 3px;
  --metal-shadow: rgba(120,120,120,.9);

  border: solid var(--metal-lift) transparent;
  padding: var(--metal-rim);
  background:
    conic-gradient(var(--metal-sheen)) content-box,
    linear-gradient(var(--metal-flat), var(--metal-flat)) padding-box,
    radial-gradient(var(--metal-shadow), transparent 70%)
      50% bottom / 80% calc(var(--metal-lift) * .75) no-repeat border-box;
  /* ⚠ the hairline is the metal's OWN hue. A grey keyline on gold reads as a
     border; the same line in the metal's colour reads as the edge of the
     material — that substitution is most of the effect. */
  box-shadow:
    inset 0 0 0 1px var(--metal-edge),
    inset 0  1px 2px rgba(255,255,255,.5),
    inset 0 -1px 2px rgba(0,0,0,.5);
}
.metal--flat{ --metal-lift: 0em; }        /* no cast shadow, for inline marks */

/* ⚠ THE BUTTON VARIANT, and read the teardown before reaching for it.
   The base part puts the sheen on the CONTENT box and uses padding as a
   machined rim — which fights a control, because a control's padding belongs
   to its label. So here the sheen moves to the PADDING box and the rim layer
   goes: the label's own padding now sits inside the metal.
   The teardown says not to use this on affordances, and that stands as the
   default. It is safe only when the metal is light enough that the DARKEST
   point of the sheen still clears 4.5:1 against the label — measure it, do not
   assume. `.metal--terracotta` was derived to clear it at 6.46:1. */
.metal--button{
  padding: var(--metal-pad, 1.05em 1.7em);
  background:
    conic-gradient(var(--metal-sheen)) padding-box,
    radial-gradient(var(--metal-shadow), transparent 70%)
      50% bottom / 80% calc(var(--metal-lift) * .75) no-repeat border-box;
}

@media (prefers-reduced-transparency: reduce){
  /* the sheen is decoration; the object still has to be an object */
  .metal{ background: var(--metal-flat) content-box, var(--metal-flat) padding-box; }
}


/* gold */
.metal--gold{
  --metal-flat: #f6d600;
  --metal-edge: #eedc00;
  --metal-sheen: #edc800, #e3b600, #f3cf00, #ffe800, #ffe900, #ffeb00, #ffe000, #ebc500, #e0b100, #f1cc00, #fcdc00, #ffe500, #fad900, #eec200, #e7b900, #f7d300, #ffe800, #ffe300, #f5d100, #e6b900, #e3b600, #f4d000, #ffe400, #ebc600, #e3b600, #f6d500, #ffe900, #ffe90a, #edc800;
}

/* silver */
.metal--silver{
  --metal-flat: #d4d4d4;
  --metal-edge: #c9c9c9;
  --metal-sheen: #d7d7d7, #c3c3c3, #cccccc, #c6c6c6, #d3d3d3, #d8d8d8, #d5d5d5, #d8d8d8, #d3d3d3, #c5c5c5, #c0c0c0, #bfbfbf, #d0d0d0, #d9d9d9, #d1d1d1, #c5c5c5, #c8c8c8, #d7d7d7, #d5d5d5, #cdcdcd, #c4c4c4, #d9d9d9, #cecece, #c5c5c5, #c5c5c5, #cdcdcd, #d8d8d8, #d9d9d9, #d7d7d7;
}

/* bronze */
.metal--bronze{
  --metal-flat: #ad3b36;
  --metal-edge: #bc7e6b;
  --metal-sheen: #d95641, #b14439, #b2453a, #d25645, #d56847, #d05441, #b85137, #b2453a, #c34f40, #df4647, #a94338, #c94943, #c85442, #a4413c, #d9543a, #d1564e, #ab4338, #bb4a3c, #dc5843, #b94839, #aa4237, #c24e42, #ce523f, #ab4338, #dd5944, #ca4d33, #ab4338, #cb503e, #d95641;
}

/* titanium */
.metal--titanium{
  --metal-flat: #e5c9be;
  --metal-edge: #c7aca0;
  --metal-sheen: #e6c9bf, #d2b5aa, #cbaea3, #d4b5ab, #e5c3bd, #d9c0b4, #d9bcb1, #c5a399, #e3c6bc, #e7cac0, #dec0b5, #d3b6ab, #cfada1, #d4b6ac, #e2c6c0, #e2c6c0, #d2b1a6, #d2b1a6, #d1b4a9, #e1c4ba, #e5c9be, #dec1b6, #d3b6ab, #ceb0a6, #cfada3, #d2b5aa, #dabdb2, #e5c9be, #e6c9bf;
}

/* terracotta — CanGo. Derived from #d68a63 with the recipe in the teardown:
   29 stops jittered within ±5.5% luminance, uneven spacing, hairline the base
   lifted 8%. Lighter than the pen's bronze so black type can sit on it. */
.metal--terracotta{
  --metal-flat: #e59267;
  --metal-edge: #ebab8a;
  --metal-sheen: #e6885c, #e18453, #de8456, #e28d67, #e29366, #e88854, #eb9266, #e08652, #e18257, #e99a75, #e7956c, #df7f54, #e69870, #e5956c, #e69e76, #ea9366, #ec966d, #e58351, #df875a, #e89a6e, #ea9d77, #e6966b, #e8a177, #e9936c, #ea9a6a, #e6895a, #df8253, #e67f51, #e6885c;
}
