/* ==========================================================================
   TypeFest materials kit (CSS side). Pairs with client/js/core/shade.js.
   One light source, up-left and warm. Shadows cool. Every surface has a
   material, every object sits on something. See ART_DIRECTION.md.
   ========================================================================== */
:root {
  /* light */
  --light-warm: #fff4d6;
  --shadow-tint: 18, 10, 42;                 /* rgb of cast shadows: deep violet, never pure black */
  --ao: rgba(var(--shadow-tint), .5);

  /* elevation: soft, physical shadows (the hard offset sticker shadow stays for keycaps and stickers only) */
  --el-1: 0 1px 1px rgba(var(--shadow-tint), .25), 0 2px 4px rgba(var(--shadow-tint), .25);
  --el-2: 0 2px 3px rgba(var(--shadow-tint), .25), 0 8px 18px rgba(var(--shadow-tint), .32);
  --el-3: 0 3px 6px rgba(var(--shadow-tint), .28), 0 18px 38px rgba(var(--shadow-tint), .42);
  --el-4: 0 6px 10px rgba(var(--shadow-tint), .3), 0 30px 70px rgba(var(--shadow-tint), .5);
  /* the lit top edge and shaded bottom edge of anything with thickness */
  --bevel: inset 0 1.5px 0 rgba(255, 255, 255, .45), inset 0 -2px 0 rgba(var(--shadow-tint), .22);
  --bevel-dark: inset 0 1px 0 rgba(255, 255, 255, .12), inset 0 -2px 0 rgba(0, 0, 0, .35);

  /* textures (tileable, tiny) */
  --tex-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  --tex-paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7 .45' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .3 0 0 0 .32 -.04'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23p)'/%3E%3C/svg%3E");
  --tex-wood: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='160'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.004 .09' numOctaves='4' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .16 0 0 0 0 .08 0 0 0 1.1 -.15'/%3E%3C/filter%3E%3Crect width='600' height='160' filter='url(%23w)'/%3E%3C/svg%3E");
  --tex-brushed: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='120'%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.002 .9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .6 0 0 0 0 .6 0 0 0 0 .62 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='400' height='120' filter='url(%23b)'/%3E%3C/svg%3E");
  --tex-fabric: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M0 0h4v4H0zM4 4h4v4H4z' fill='%23000' fill-opacity='.07'/%3E%3C/svg%3E");
}

/* Film grain over a whole scene: kills the flat-vector look. Put .grain on an already-positioned container,
   or use a <div class="grain-layer"> overlay when ::after is taken (e.g. .game-area, whose ::after is the danger vignette).
   Normal blending on purpose: a full-screen mix-blend-mode re-composites every animated frame (measured: ~5x slower). */
.grain::after, .grain-layer { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 30; background-image: var(--tex-noise); background-size: 180px; opacity: .045; }
/* Lens vignette: pulls the eye to the middle. */
.vignette::before { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 29;
  background: radial-gradient(120% 95% at 50% 45%, transparent 55%, rgba(var(--shadow-tint), .55) 100%); }

/* Materials for HTML surfaces. Set --m (base colour) and pick one. */
.mat-plastic { background: linear-gradient(165deg, color-mix(in oklab, var(--m) 78%, white) 0%, var(--m) 38%, color-mix(in oklab, var(--m) 80%, rgb(var(--shadow-tint))) 100%);
  box-shadow: var(--bevel), var(--el-2); }
.mat-matte { background: var(--tex-noise) 0 0 / 180px, linear-gradient(170deg, color-mix(in oklab, var(--m) 88%, white), color-mix(in oklab, var(--m) 86%, rgb(var(--shadow-tint))));
  background-blend-mode: soft-light, normal; box-shadow: var(--bevel), var(--el-2); }
.mat-paper { background: var(--tex-paper) 0 0 / 300px, linear-gradient(175deg, #fffaf0, #f6ead2); background-blend-mode: multiply, normal; box-shadow: var(--el-2); }
.mat-wood { background: var(--tex-wood) 0 0 / 600px 160px, linear-gradient(180deg, #9a5f35, #6e3f22); background-blend-mode: multiply, normal; }
.mat-metal { background: var(--tex-brushed) 0 0 / 400px 120px, linear-gradient(180deg, #e9ecf2 0%, #b8bec9 45%, #8d93a0 52%, #c9ced8 100%); background-blend-mode: overlay, normal;
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 rgba(0,0,0,.3), var(--el-2); }
.mat-glass { background: linear-gradient(125deg, rgba(255,255,255,.34) 0 18%, rgba(255,255,255,.06) 18% 30%, rgba(255,255,255,.16) 30% 33%, rgba(255,255,255,.04) 33%);
  backdrop-filter: blur(2px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.mat-screen { background: radial-gradient(130% 120% at 30% 20%, color-mix(in oklab, var(--m) 70%, white) 0%, var(--m) 40%, color-mix(in oklab, var(--m) 55%, black) 100%);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.5), inset 0 0 40px rgba(0,0,0,.45), 0 0 30px color-mix(in oklab, var(--m) 50%, transparent); }

/* A soft contact shadow under an object that sits on a surface (absolutely positioned helper). */
.contact-shadow { position: absolute; left: 8%; right: 8%; bottom: -14px; height: 26px; border-radius: 50%; pointer-events: none; z-index: -1;
  background: radial-gradient(closest-side, rgba(var(--shadow-tint), .55), rgba(var(--shadow-tint), .2) 60%, transparent); filter: blur(2px); }
