@layer reset, tokens, base, layout, components, utilities, overrides;

@layer tokens {
  @property --art-ready {
    syntax: "<number>";
    inherits: true;
    initial-value: 0;
  }

  :root {
    --color-ink: oklch(15% 0.02 245);
    --color-ink-dot: oklch(15% 0.02 245 / 0.16);
    --color-cream: oklch(97% 0.025 90);
    --color-cream-dim: oklch(86% 0.03 90);
    --color-teal: oklch(52% 0.085 200);
    --color-cherry: oklch(58% 0.19 28);
    --color-mustard: oklch(81% 0.15 83);
    --font-sign: "Futura", "Century Gothic", "Avenir Next", "Trebuchet MS", system-ui, sans-serif;

    --turquoise-400: oklch(72% 0.11 195);
    --steel-400: oklch(70% 0.02 235);
    --chrome-200: oklch(88% 0.02 225);
    --chrome-50: oklch(98% 0.01 220);

    --color-enamel-turquoise: var(--turquoise-400);
    --color-enamel-mustard: var(--color-mustard);
    --color-enamel-cherry: var(--color-cherry);
    --color-enamel-cream: var(--color-cream);
    --color-chrome-satin: var(--steel-400);
    --color-chrome-gleam: var(--chrome-200);
    --color-chrome-shine: var(--chrome-50);
    --color-floor-shadow: color-mix(in oklch, var(--color-ink) 45%, transparent);
    --pattern-glint: linear-gradient(100deg, transparent 0 20%, var(--color-chrome-shine) 20% 27%, transparent 27% 33%, var(--color-chrome-shine) 33% 36%, transparent 36%);

    --duration-paint: 400ms;
    --duration-pop: 480ms;
    --duration-settle: 300ms;
    --ease-pop: linear(0, 0.62 35%, 1.08 64%, 0.98 84%, 1);

    --navy-900: oklch(21% 0.045 255);
    --steel-600: oklch(50% 0.02 235);
    --glass-800: oklch(30% 0.05 230);
    --roast-500: oklch(48% 0.12 45);

    --color-burner: var(--navy-900);
    --color-coil: var(--steel-600);
    --color-glass: var(--glass-800);
    --color-glass-sheen: color-mix(in oklch, var(--color-cream) 22%, transparent);
    --color-roast: var(--roast-500);
    --color-twine: var(--color-cream-dim);
    --pattern-glass: linear-gradient(120deg, transparent 0 16%, var(--color-glass-sheen) 16% 24%, transparent 24% 29%, var(--color-glass-sheen) 29% 32%, transparent 32%);
    --shape-burst-24: polygon(50% 0%, 55.4% 9.4%, 62.9% 1.7%, 65.7% 12.1%, 75% 6.7%, 75% 17.5%, 85.4% 14.6%, 82.5% 25%, 93.3% 25%, 87.9% 34.3%, 98.3% 37.1%, 90.6% 44.6%, 100% 50%, 90.6% 55.4%, 98.3% 62.9%, 87.9% 65.7%, 93.3% 75%, 82.5% 75%, 85.4% 85.4%, 75% 82.5%, 75% 93.3%, 65.7% 87.9%, 62.9% 98.3%, 55.4% 90.6%, 50% 100%, 44.6% 90.6%, 37.1% 98.3%, 34.3% 87.9%, 25% 93.3%, 25% 82.5%, 14.6% 85.4%, 17.5% 75%, 6.7% 75%, 12.1% 65.7%, 1.7% 62.9%, 9.4% 55.4%, 0% 50%, 9.4% 44.6%, 1.7% 37.1%, 12.1% 34.3%, 6.7% 25%, 17.5% 25%, 14.6% 14.6%, 25% 17.5%, 25% 6.7%, 34.3% 12.1%, 37.1% 1.7%, 44.6% 9.4%);
  }
}

@layer components {
  .art {
    --u: calc(100cqi / var(--grid-w));
    --art-line: calc(3.5 * var(--line-scale, 1) * var(--u));
    --art-slip-x: calc(-5 * var(--line-scale, 1) * var(--u));
    --art-slip-y: calc(-4 * var(--line-scale, 1) * var(--u));
    --art-grain: radial-gradient(circle, var(--color-ink-dot) 32%, transparent 36%) 0 0 / calc(7 * var(--u)) calc(7 * var(--u));
    --paint: var(--enamel, var(--paint-default));
    --accent: var(--enamel-accent, var(--accent-default));
    --chrome: var(--trim, var(--color-chrome-satin));
    --glint: var(--trim-glint, none);

    position: relative;
    container-type: inline-size;
    isolation: isolate;
    inline-size: min(100%, var(--art-max-b, 200dvh) * var(--grid-w) / var(--grid-h));
    aspect-ratio: var(--grid-w) / var(--grid-h);
    margin-inline: auto;
    font-family: var(--font-sign);
    forced-color-adjust: none;

    & > :where(*) {
      position: absolute;
      inset-inline-start: calc(var(--x) * var(--u));
      inset-block-start: calc(var(--y) * var(--u));
      inline-size: calc(var(--w) * var(--u));
      block-size: calc(var(--h) * var(--u));
    }

    & :where(.shape) {
      background: var(--art-grain), var(--pattern, none), var(--fill, transparent);

      &::after {
        content: "";
        position: absolute;
        inset: var(--outline-inset, 0);
        border: var(--art-line) solid var(--color-ink);
        border-radius: inherit;
        translate: var(--art-slip-x) var(--art-slip-y);
        pointer-events: none;
      }
    }

    & :where(.cut) {
      &::before,
      &::after {
        content: "";
        position: absolute;
        clip-path: var(--shape);
      }

      &::before {
        inset: 0;
        background: var(--color-ink);
        translate: var(--art-slip-x) var(--art-slip-y);
      }

      &::after {
        inset: var(--art-line);
        background: var(--art-grain), var(--pattern, none), var(--fill);
      }
    }

    & :where(.type) {
      display: grid;
      place-items: center;
      color: var(--accent);
      font-size: calc(var(--type-size) * var(--u));
      font-style: italic;
      font-weight: 900;
      letter-spacing: 0.04em;
      line-height: 1;
      text-shadow: calc(-3 * var(--u)) calc(-2 * var(--u)) 0 var(--color-ink);
      text-transform: uppercase;
      white-space: nowrap;
    }

    & :where(.floor) {
      border-radius: 50%;
      background: var(--color-floor-shadow);
    }

    & :where(.pull) {
      --fill: var(--chrome);
      --pattern: var(--glint);

      border-radius: calc(8 * var(--u));
    }
  }

  .art[data-model="range"] {
    --grid-w: 600;
    --grid-h: 660;
    --paint-default: var(--color-enamel-turquoise);
    --accent-default: var(--color-cherry);

    & :where(.floor) {
      --x: 14;
      --y: 624;
      --w: 572;
      --h: 26;
    }

    & :where(.backguard) {
      --x: 40;
      --y: 22;
      --w: 520;
      --h: 128;
      --fill: var(--paint);

      border-radius: calc(44 * var(--u)) calc(44 * var(--u)) calc(4 * var(--u)) calc(4 * var(--u));
    }

    & :where(.panel) {
      --x: 62;
      --y: 98;
      --w: 476;
      --h: 38;
      --fill: var(--chrome);
      --pattern: var(--glint);

      border-radius: calc(19 * var(--u));
    }

    & :where(.knob) {
      --y: 94;
      --w: 46;
      --h: 46;
      --fill: var(--color-cream);
      --pattern: linear-gradient(var(--color-ink), var(--color-ink)) 50% 14% / calc(5 * var(--u)) calc(14 * var(--u)) no-repeat;

      border-radius: 50%;
    }

    & :where(.knob[data-n="1"]) {
      --x: 84;
    }

    & :where(.knob[data-n="2"]) {
      --x: 140;
    }

    & :where(.knob[data-n="3"]) {
      --x: 414;
    }

    & :where(.knob[data-n="4"]) {
      --x: 470;
    }

    & :where(.nameplate) {
      --x: 190;
      --y: 36;
      --w: 220;
      --h: 54;
      --type-size: 34;

      opacity: calc(1 - var(--clock, 0));
    }

    & :where(.sunburst) {
      --x: 236;
      --y: 4;
      --w: 128;
      --h: 128;
      --shape: var(--shape-burst-24);
      --fill: var(--accent);

      scale: var(--clock, 0);
    }

    & :where(.clock, .hands) {
      --x: 266;
      --y: 34;
      --w: 68;
      --h: 68;

      border-radius: 50%;
      scale: var(--clock, 0);
    }

    & :where(.clock) {
      --fill: var(--color-cream);

      box-shadow: inset 0 0 0 calc(7 * var(--u)) var(--chrome);
    }

    & :where(.hands) {
      background: radial-gradient(circle, var(--color-cherry) 0 calc(5 * var(--u)), transparent calc(5.5 * var(--u)));

      &::before,
      &::after {
        content: "";
        position: absolute;
        inset-block-end: 50%;
        inset-inline-start: calc(50% - 2.5 * var(--u));
        inline-size: calc(5 * var(--u));
        border-radius: calc(3 * var(--u));
        background: var(--color-ink);
        transform-origin: 50% 100%;
      }

      &::before {
        block-size: 26%;
        rotate: -60deg;
      }

      &::after {
        block-size: 36%;
        rotate: 60deg;
      }
    }

    & :where(.cooktop) {
      --x: 22;
      --y: 146;
      --w: 556;
      --h: 44;
      --fill: var(--color-cream);

      border-radius: calc(6 * var(--u));
    }

    & :where(.burner) {
      --y: 157;
      --w: 96;
      --h: 22;
      --fill: var(--color-burner);
      --pattern: repeating-radial-gradient(closest-side, transparent 0 18%, var(--color-coil) 18% 30%);

      border-radius: 50%;
    }

    & :where(.burner[data-n="1"]) {
      --x: 50;
    }

    & :where(.burner[data-n="2"]) {
      --x: 160;
    }

    & :where(.burner[data-n="3"]) {
      --x: 344;
    }

    & :where(.burner[data-n="4"]) {
      --x: 454;
    }

    & :where(.griddle) {
      --x: 262;
      --y: 155;
      --w: 76;
      --h: 26;
      --fill: var(--color-burner);
      --pattern: repeating-linear-gradient(90deg, transparent 0 calc(8 * var(--u)), var(--color-coil) calc(8 * var(--u)) calc(10 * var(--u)));

      border-radius: calc(4 * var(--u));
      scale: var(--griddle, 0);
    }

    & :where(.body) {
      --x: 30;
      --y: 190;
      --w: 540;
      --h: 424;
      --fill: var(--paint);

      border-radius: calc(4 * var(--u)) calc(4 * var(--u)) calc(8 * var(--u)) calc(8 * var(--u));
    }

    & :where(.strip) {
      --x: 30;
      --y: 190;
      --w: 540;
      --h: 14;
      --fill: var(--chrome);
      --pattern: var(--glint);
    }

    & :where(.door) {
      --fill: var(--paint);

      border-radius: calc(10 * var(--u));
      box-shadow:
        inset 0 0 0 calc(8 * var(--u)) var(--paint),
        inset 0 0 0 calc(11 * var(--u)) color-mix(in oklch, var(--paint), var(--color-ink) 22%);
    }

    & :where(.door[data-n="oven"]) {
      --x: 52;
      --y: 218;
      --w: 300;
      --h: 288;
    }

    & :where(.door[data-n="broiler"]) {
      --x: 372;
      --y: 218;
      --w: 176;
      --h: 182;
    }

    & :where(.door[data-n="drawer"]) {
      --x: 372;
      --y: 414;
      --w: 176;
      --h: 186;
    }

    & :where(.door[data-n="bin"]) {
      --x: 52;
      --y: 520;
      --w: 300;
      --h: 80;
    }

    & :where(.pull[data-n="oven"]) {
      --x: 72;
      --y: 232;
      --w: 260;
      --h: 16;
    }

    & :where(.pull[data-n="broiler"]) {
      --x: 392;
      --y: 232;
      --w: 136;
      --h: 16;
    }

    & :where(.pull[data-n="drawer"]) {
      --x: 410;
      --y: 428;
      --w: 100;
      --h: 14;
    }

    & :where(.pull[data-n="bin"]) {
      --x: 142;
      --y: 534;
      --w: 120;
      --h: 14;
    }

    & :where(.window, .glare) {
      --x: 92;
      --y: 268;
      --w: 220;
      --h: 150;

      border-radius: calc(14 * var(--u));
    }

    & :where(.window) {
      --fill: var(--color-glass);
    }

    & :where(.glare) {
      background: var(--pattern-glass);
    }

    & :where(.rack) {
      --x: 100;
      --y: 390;
      --w: 204;
      --h: 5;

      background: var(--chrome);
    }

    & :where(.spit) {
      --x: 100;
      --y: 340;
      --w: 204;
      --h: 6;

      background: var(--chrome);
      scale: var(--rotisserie, 0) 1;
    }

    & :where(.roast) {
      --x: 162;
      --y: 314;
      --w: 80;
      --h: 58;
      --fill: var(--color-roast);
      --pattern: repeating-linear-gradient(90deg, transparent 0 calc(16 * var(--u)), var(--color-twine) calc(16 * var(--u)) calc(19 * var(--u)));

      border-radius: 50%;
      scale: var(--rotisserie, 0);
    }

    & :where(.fork) {
      --y: 324;
      --w: 8;
      --h: 38;

      border-radius: calc(3 * var(--u));
      background: var(--chrome);
      scale: 1 var(--rotisserie, 0);
    }

    & :where(.fork[data-n="1"]) {
      --x: 152;
    }

    & :where(.fork[data-n="2"]) {
      --x: 244;
    }

    & :where(.maker-mark) {
      --x: 122;
      --y: 446;
      --w: 160;
      --h: 34;
      --type-size: 22;
    }

    & :where(.kick) {
      --x: 46;
      --y: 614;
      --w: 508;
      --h: 22;
      --fill: var(--chrome);
      --pattern: var(--glint);

      border-radius: 0 0 calc(4 * var(--u)) calc(4 * var(--u));
    }
  }

  .art[data-enamel="turquoise"] {
    --enamel: var(--color-enamel-turquoise);
    --enamel-accent: var(--color-cherry);
  }

  .art[data-enamel="mustard"] {
    --enamel: var(--color-enamel-mustard);
    --enamel-accent: var(--color-teal);
  }

  .art[data-enamel="cherry"] {
    --enamel: var(--color-enamel-cherry);
    --enamel-accent: var(--color-mustard);
  }

  .art[data-enamel="cream"] {
    --enamel: var(--color-enamel-cream);
    --enamel-accent: var(--color-teal);
  }

  .art[data-trim="gleam"] {
    --trim: var(--color-chrome-gleam);
    --trim-glint: var(--pattern-glint);
  }

  .art[data-with~="clock"] {
    --clock: 1;
  }

  .art[data-with~="rotisserie"] {
    --rotisserie: 1;
  }

  .art[data-with~="griddle"] {
    --griddle: 1;
  }

  @keyframes art-ready {
    from {
      --art-ready: 0;
    }

    to {
      --art-ready: 1;
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    .art {
      animation: art-ready 0s var(--duration-settle) both;
    }

    @container style(--art-ready: 1) {
      .art > :where(*) {
        transition:
          scale var(--duration-pop) var(--ease-pop),
          translate var(--duration-pop) var(--ease-pop),
          opacity var(--duration-paint) ease,
          color var(--duration-paint) ease,
          background-color var(--duration-paint) ease,
          box-shadow var(--duration-paint) ease;
      }

      .art :where(.cut)::after {
        transition: background-color var(--duration-paint) ease;
      }
    }
  }
}
