/* Built by kit/build.mjs from kit/src/themes/materials.css: edit that, not this. Link it after kit.css. */
/*
 * Tactile UI Kit, Materials: porcelain and black.
 *
 * Two more things the same parts can be made of, lit by the same lamp, high
 * and to the left. Link this after kit.css, and put data-finish="porcelain"
 * (data-tone="light") or data-finish="black" (data-tone="dark") on <html> or
 * on any element; setFinish() in kit/finishes.mjs sets both.
 *
 *   porcelain  Glazed white porcelain: whiter and cooler than aluminium,
 *              smooth instead of grained, a wet highlight toward the lamp
 *              and a cool blue-grey shade under every raised part.
 *   black      Black anodised aluminium on a page that is almost black (grey
 *              5: black to the eye, but never a pixel switched off, so
 *              nothing smears as it scrolls on an OLED screen). The plate
 *              shows itself where a diamond-cut chamfer catches the lamp;
 *              the contrast key is the one part left raw, bare aluminium.
 *
 * Tokens first, about fifty to each finish with its Quiet volume. Then the
 * few places a part draws its material in the rule itself (a glaze's window
 * of light, a rim, the knob's face), scoped so they stop at any element with
 * a finish of its own and at a Quiet region, which draws its own light.
 */

[data-finish="porcelain"] {
  color-scheme: light;
  --tui-red-ink: oklch(from var(--tui-red) 0.4697 calc(c * 0.8316) calc(h - 0.29));
  --tui-desk: var(--tn-desk, #d2d6d9); --tn-desk: color-mix(in oklab, #d2d6d9, oklch(from #d2d6d9 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));          /* a cool grey table, so the white reads as white */
  --tui-face: var(--tn-face, #f8f9f9); --tn-face: color-mix(in oklab, #f8f9f9, oklch(from #f8f9f9 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));          /* glazed porcelain */
  --tui-face-hi: var(--tn-face-hi, #ffffff); --tn-face-hi: color-mix(in oklab, #ffffff, oklch(from #ffffff l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-face-lo: var(--tn-face-lo, #e1e4e7); --tn-face-lo: color-mix(in oklab, #e1e4e7, oklch(from #e1e4e7 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-tactile-well: var(--tn-tactile-well, #eceef0); --tn-tactile-well: color-mix(in oklab, #eceef0, oklch(from #eceef0 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));  /* a recess in porcelain is glazed too: smooth, just darker */
  --tui-skirt: var(--tn-skirt, #646c77); --tn-skirt: color-mix(in oklab, #646c77, oklch(from #646c77 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));         /* the side of a white cap is in cool shade, deep enough to show the key at 3:1 */
  --tui-edge-sh: rgb(40 52 72 / 0.8);  /* where the plate meets a pressed key */
  --tui-ink: var(--tn-ink, #15171a); --tn-ink: color-mix(in oklab, #15171a, oklch(from #15171a l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-ink-2: var(--tn-ink-2, #454950); --tn-ink-2: color-mix(in oklab, #454950, oklch(from #454950 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-ink-3: var(--tn-ink-3, #62666d); --tn-ink-3: color-mix(in oklab, #62666d, oklch(from #62666d l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-rule: var(--tn-rule, rgb(21 23 26 / 0.12)); --tn-rule: color-mix(in oklab, rgb(21 23 26 / 0.12), oklch(from rgb(21 23 26 / 0.12) l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-cap: #121316;           /* the contrast key: black glazed porcelain */
  --tui-cap-hi: #2e3034;
  --tui-cap-skirt: #000;
  --tui-cap-ink: #f6f7f7;
  --tui-hl: #ffffff;            /* glaze takes the lamp as pure white */
  --tui-sh: 40 52 72;           /* shade on white porcelain is cool: the sky in the glaze */
  --tui-sh-a: 0.22;
  --tui-tactile-grain: 0;       /* glazed: no grain at all */
  --tui-focus: var(--tb-edge, #15171a);
  --tui-cap-hl: rgb(255 255 255 / 0.35);
  --tui-rocker-hi: #ffffff; --tui-rocker-mid: #eef0f2; --tui-rocker-lo: #d6dade; --tui-rocker-sunk: #c3c8cd; --tui-rocker-wall: #9aa1a8;
  --tui-rocker-mark: #15171a; --tui-rocker-bezel: linear-gradient(#0c0d0f, #1c1e21);
  --tui-knob-hi: #ffffff; --tui-knob-mid: #eceef1; --tui-knob-lo: #b1b8c0;
  --tui-knob-cap-shadow: inset 0 1px 1px #fff, inset 0 -2px 3px rgb(40 52 72 / 0.25), 0 1px 2px rgb(40 52 72 / 0.35);
  --tui-cloth: #2a2c30;
  --tui-backdrop: rgb(30 34 42 / 0.4);
  --tui-tactile-well-fill: linear-gradient(to bottom, color-mix(in oklab, var(--tui-tactile-well) 91%, rgb(var(--tui-sh))), var(--tui-tactile-well) 40%, #f4f5f6);
  /* A glazed recess keeps a fine dark line where the glaze breaks over its rim. */
  --tui-inset: var(--tui-depth-well, inset 0 0 0 1px rgb(40 52 72 / 0.68), inset 0 3px 4px -2px rgb(40 52 72 / 0.3), inset 0 -1px 0 #fff, 0 1px 0 #fff);
  --tui-quiet-well: var(--tn-quiet-well, #eff1f2); --tn-quiet-well: color-mix(in oklab, #eff1f2, oklch(from #eff1f2 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-quiet-key: var(--tn-quiet-key, #ffffff); --tn-quiet-key: color-mix(in oklab, #ffffff, oklch(from #ffffff l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p)); --tui-quiet-key-hover: var(--tn-quiet-key-hover, #fbfbfb); --tn-quiet-key-hover: color-mix(in oklab, #fbfbfb, oklch(from #fbfbfb l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p)); --tui-quiet-key-down: var(--tn-quiet-key-down, #f0f2f3); --tn-quiet-key-down: color-mix(in oklab, #f0f2f3, oklch(from #f0f2f3 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-quiet-line: var(--tn-quiet-line, rgb(21 23 26 / 0.12)); --tn-quiet-line: color-mix(in oklab, rgb(21 23 26 / 0.12), oklch(from rgb(21 23 26 / 0.12) l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p)); --tui-quiet-line-2: var(--tn-quiet-line-2, rgb(21 23 26 / 0.2)); --tn-quiet-line-2: color-mix(in oklab, rgb(21 23 26 / 0.2), oklch(from rgb(21 23 26 / 0.2) l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-quiet-edge: var(--tn-quiet-edge, rgb(21 23 26 / 0.58)); --tn-quiet-edge: color-mix(in oklab, rgb(21 23 26 / 0.58), oklch(from rgb(21 23 26 / 0.58) l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-quiet-hl: #ffffff;
  --tui-quiet-whisper: 0 1px 2px rgb(40 52 72 / 0.1);
  --tui-quiet-shade: rgb(40 52 72 / 0.14);
  --tui-quiet-cap-hover: #2b2d31; --tui-quiet-cap-down: #0d0e10; --tui-quiet-cap-ring: rgb(0 0 0 / 0.5); --tui-quiet-cap-hl: rgb(255 255 255 / 0.2);
  /* An object drawn in this finish (its plate, the material in shadow, mid tone, lit, hotspot, the room in it, frame, edge; shadow alpha; 1 for matte; its markings, and how much they and its edges glow): bead-blasted aluminium. */
  --tui-obj-plate: #c9cac5; --tui-obj-dark: #6f747b; --tui-obj-body: #aeb4bb; --tui-obj-lite: #ffffff; --tui-obj-spec: #ffffff;
  --tui-obj-env: #dde4ec; --tui-obj-frame: #bfc0bb; --tui-obj-edge: #f6f7f8; --tui-obj-shadow: 0.34; --tui-obj-matte: 0;
  --tui-obj-mark: #15171a; --tui-obj-glow: 0;
}

[data-finish="black"] {
  color-scheme: dark;
  --tui-red-ink: oklch(from var(--tui-red) 0.7192 calc(c * 0.8845) calc(h - 0.96));
  --tui-desk: var(--tn-desk, #050506); --tn-desk: color-mix(in oklab, #050506, oklch(from #050506 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));          /* grey 5: black to the eye, never a pixel fully off */
  --tui-face: var(--tn-face, #0a0a0b); --tn-face: color-mix(in oklab, #0a0a0b, oklch(from #0a0a0b l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));          /* black anodised plate */
  --tui-face-hi: var(--tn-face-hi, #1a1a1c); --tn-face-hi: color-mix(in oklab, #1a1a1c, oklch(from #1a1a1c l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));       /* caps and thumbs: satin, a step lighter where they face the lamp */
  --tui-face-lo: var(--tn-face-lo, #060607); --tn-face-lo: color-mix(in oklab, #060607, oklch(from #060607 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-tactile-well: var(--tn-tactile-well, #020202); --tn-tactile-well: color-mix(in oklab, #020202, oklch(from #020202 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-skirt: var(--tn-skirt, #000); --tn-skirt: color-mix(in oklab, #000, oklch(from #000 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-ink: var(--tn-ink, #e6e4df); --tn-ink: color-mix(in oklab, #e6e4df, oklch(from #e6e4df l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));           /* printing: warm white, never #fff (white on black blooms) */
  --tui-ink-2: var(--tn-ink-2, #a5a49f); --tn-ink-2: color-mix(in oklab, #a5a49f, oklch(from #a5a49f l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-ink-3: var(--tn-ink-3, #83827e); --tn-ink-3: color-mix(in oklab, #83827e, oklch(from #83827e l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-rule: var(--tn-rule, rgb(230 228 223 / 0.13)); --tn-rule: color-mix(in oklab, rgb(230 228 223 / 0.13), oklch(from rgb(230 228 223 / 0.13) l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-cap: #c3c5c7;           /* the contrast key: raw aluminium, the one part not anodised */
  --tui-cap-hi: #dcdee0;
  --tui-cap-skirt: #66686b;
  --tui-cap-ink: #0b0c0d;
  --tui-hl: rgb(255 255 255 / 0.42);     /* the chamfer: diamond-cut, bright, one pixel */
  --tui-sheen: rgb(255 255 255 / 0.07);  /* the cap's broad sheen: anodising is satin, so the chamfer and the sheen part ways */
  --tui-edge-hl: rgb(255 255 255 / 0.5);  /* the chamfer along a control's edge, a little brighter so the control shows at 3:1 */
  --tui-sh: 0 0 0;
  --tui-sh-a: 0.85;
  --tui-tactile-grain: 0.2;
  --tui-focus: var(--tb-edge, #e6e4df);
  --tui-cap-hl: rgb(255 255 255 / 0.9);
  --tui-rocker-hi: #3f4043; --tui-rocker-mid: #2b2c2f; --tui-rocker-lo: #1d1e20; --tui-rocker-sunk: #131415; --tui-rocker-wall: #070708;
  --tui-rocker-mark: #e6e4df; --tui-rocker-bezel: linear-gradient(#000, #050506);
  --tui-knob-hi: #6a6c70; --tui-knob-mid: #1f2023; --tui-knob-lo: #08080a;
  --tui-knob-cap-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12), inset 0 1px 0.5px rgb(255 255 255 / 0.5), inset 0 -1px 2px rgb(0 0 0 / 0.7), 0 1px 2px rgb(0 0 0 / 0.9);
  --tui-cloth: #0f1012;
  --tui-backdrop: rgb(0 0 0 / 0.72);
  --tui-tactile-well-fill: linear-gradient(to bottom, #000, var(--tui-tactile-well) 45%, #0c0c0d);
  /* A recess cut through the anodising: dark inside, and the cut's lower lip bright where the lamp finds it. */
  --tui-inset: var(--tui-depth-well, inset 0 -1px 0 rgb(255 255 255 / 0.3), inset 0 3px 3px -2px #000, inset 0 0 0 1px rgb(0 0 0 / 0.9), 0 1px 0 rgb(255 255 255 / 0.5), 0 -1px 0 rgb(255 255 255 / 0.1));
  /* Blasted finer than the aluminium's bead-blast, and paler, so it shows on black. */
  --tui-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='1.6' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.6 0 0 0 0 0.6 0 0 0 0 0.62 0 0 0 0.18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --tui-quiet-well: var(--tn-quiet-well, #040404); --tn-quiet-well: color-mix(in oklab, #040404, oklch(from #040404 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-quiet-key: var(--tn-quiet-key, #161618); --tn-quiet-key: color-mix(in oklab, #161618, oklch(from #161618 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p)); --tui-quiet-key-hover: var(--tn-quiet-key-hover, #1b1b1d); --tn-quiet-key-hover: color-mix(in oklab, #1b1b1d, oklch(from #1b1b1d l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p)); --tui-quiet-key-down: var(--tn-quiet-key-down, #101011); --tn-quiet-key-down: color-mix(in oklab, #101011, oklch(from #101011 l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-quiet-line: var(--tn-quiet-line, rgb(230 228 223 / 0.16)); --tn-quiet-line: color-mix(in oklab, rgb(230 228 223 / 0.16), oklch(from rgb(230 228 223 / 0.16) l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p)); --tui-quiet-line-2: var(--tn-quiet-line-2, rgb(230 228 223 / 0.26)); --tn-quiet-line-2: color-mix(in oklab, rgb(230 228 223 / 0.26), oklch(from rgb(230 228 223 / 0.26) l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-quiet-edge: var(--tn-quiet-edge, rgb(230 228 223 / 0.46)); --tn-quiet-edge: color-mix(in oklab, rgb(230 228 223 / 0.46), oklch(from rgb(230 228 223 / 0.46) l calc(sqrt(l) * 0.065) var(--tui-tone)) var(--tn-p));
  --tui-quiet-hl: rgb(255 255 255 / 0.14);
  --tui-quiet-whisper: 0 1px 2px rgb(0 0 0 / 0.6);
  --tui-quiet-shade: rgb(0 0 0 / 0.6);
  --tui-quiet-cap-hover: #d4d6d8; --tui-quiet-cap-down: #aeb0b3; --tui-quiet-cap-ring: rgb(0 0 0 / 0.6); --tui-quiet-cap-hl: rgb(255 255 255 / 0.7);
  /* An object drawn in this finish (its plate, the material in shadow, mid tone, lit, hotspot, the room in it, frame, edge; shadow alpha; 1 for matte; its markings, and how much they and its edges glow): black anodised, darker still, a bright diamond-cut chamfer. */
  --tui-obj-plate: #050506; --tui-obj-dark: #070708; --tui-obj-body: #3f434a; --tui-obj-lite: #cfd4da; --tui-obj-spec: #ffffff;
  --tui-obj-env: #66707d; --tui-obj-frame: #0e0e10; --tui-obj-edge: #f0f2f4; --tui-obj-shadow: 0.6; --tui-obj-matte: 0;
  --tui-obj-mark: #e6e4df; --tui-obj-glow: 0;
}

/* ------------------------------------------------------------------ porcelain, drawn */

@scope ([data-finish="porcelain"]:not([data-volume="quiet"])) to (:scope [data-finish], [data-volume="quiet"]) {
  /* The glaze holds a window of light across the plate, up toward the lamp. */
  .tui-panel::before {
    background: linear-gradient(162deg, rgb(255 255 255 / 0.95) 0, rgb(255 255 255 / 0.5) 18%, transparent 42%), linear-gradient(to bottom, transparent 60%, rgb(40 52 72 / 0.035));
    opacity: 1;
  }
  /* The black cap is glazed too: a small, sharp window of the lamp on it. */
  .tui-key--primary {
    background:
      radial-gradient(38% 42% at 24% 14%, rgb(255 255 255 / 0.38), transparent 100%),
      linear-gradient(var(--tui-cap-hi), var(--tui-cap));
  }
  /* The lamp green alone is 2.7:1 on white glaze: an "on" slot keeps a dark rim, so its edge still reads. */
  .tui-switch:checked { box-shadow: inset 0 0 0 1px rgb(20 66 32 / 0.62), inset 0 1.5px 3px rgb(0 0 0 / 0.22), 0 1px 0 #fff, 0 0 10px -2px color-mix(in oklab, var(--tui-green) 60%, transparent); }
  :is(.tui-check, .tui-radio) { box-shadow: inset 0 0 0 1px rgb(40 52 72 / 0.7), inset 0 1px 0 #fff, 0 1.5px 0 var(--tui-skirt), 0 2px 3px rgb(var(--tui-sh) / 0.3); }
  :is(.tui-check, .tui-radio):checked { box-shadow: inset 0 0 0 1px rgb(40 52 72 / 0.62), var(--tui-pressed); }
  .tui-select { background: linear-gradient(45deg, transparent 50%, var(--tui-ink-2) 50%) calc(100% - 17px) 55% / 5px 5px no-repeat, linear-gradient(-45deg, transparent 50%, var(--tui-ink-2) 50%) calc(100% - 12px) 55% / 5px 5px no-repeat, var(--tui-well-fill) var(--tui-well); }
  /* A porcelain knob is a glazed dome on a fluted foot: no spun metal in it. A black knob (data-knob) stays black. */
  tui-knob:not([data-knob]) .tui-knob__body { box-shadow: 0 0 0 1px rgb(40 52 72 / 0.6), 0 1px 1.5px rgb(40 52 72 / 0.35), 3px 7px 14px -6px rgb(40 52 72 / 0.45); }
  tui-knob:not([data-knob]) .tui-knob__knurl { background: repeating-conic-gradient(from 0deg, rgb(40 52 72 / 0.18) 0 4deg, rgb(255 255 255 / 0.55) 4deg 6deg, transparent 6deg 12deg); }
  tui-knob:not([data-knob]) .tui-knob__cap { background: radial-gradient(34% 30% at 32% 26%, #fff 0 50%, transparent 100%), radial-gradient(circle at 50% 42%, #fdfdfd, #e4e8eb 68%, #cdd3d9); }
  tui-knob:not([data-knob]) .tui-knob__sheen { background: linear-gradient(150deg, rgb(255 255 255 / 0.75), transparent 45%, transparent 60%, rgb(40 52 72 / 0.24)); }
}

/* ------------------------------------------------------------------ black, drawn */

@scope ([data-finish="black"]:not([data-volume="quiet"])) to (:scope [data-finish], [data-volume="quiet"]) {
  .tui-select { background: linear-gradient(45deg, transparent 50%, var(--tui-ink-2) 50%) calc(100% - 17px) 55% / 5px 5px no-repeat, linear-gradient(-45deg, transparent 50%, var(--tui-ink-2) 50%) calc(100% - 12px) 55% / 5px 5px no-repeat, var(--tui-well-fill) var(--tui-well); }
  /* The knob: spun black anodising, its knurl cut through to bright metal at every ridge. */
  tui-knob .tui-knob__body { box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.36), inset 1px 1px 0 1px rgb(255 255 255 / 0.18), 0 1px 1.5px #000, 3px 7px 14px -6px #000; }
  tui-knob .tui-knob__knurl { background: repeating-conic-gradient(from 0deg, rgb(0 0 0 / 0.45) 0 2.2deg, rgb(255 255 255 / 0.6) 2.2deg 3deg, transparent 3deg 6deg); }
  tui-knob .tui-knob__sheen { background: linear-gradient(150deg, rgb(255 255 255 / 0.32), transparent 40%, transparent 60%, rgb(0 0 0 / 0.5)); }
}
