@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);

    --color-burner: var(--navy-900);
  }
}

@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="cabinet"] {
    --grid-w: 240;
    --grid-h: 492;
    --paint-default: var(--color-teal);
    --accent-default: var(--color-cherry);

    & :where(.floor) {
      --x: 4;
      --y: 462;
      --w: 232;
      --h: 26;
    }

    & :where(.kick) {
      --x: 20;
      --y: 446;
      --w: 200;
      --h: 28;

      background: var(--color-burner);
    }

    & :where(.cabinet, .drawer, .cupboard) {
      --fill: var(--color-cream);

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

    & :where(.cabinet) {
      --x: 8;
      --y: 22;
      --w: 224;
      --h: 430;
    }

    & :where(.drawer) {
      --x: 22;
      --y: 36;
      --w: 196;
      --h: 72;
    }

    & :where(.cupboard) {
      --x: 22;
      --y: 122;
      --w: 196;
      --h: 316;
    }

    & :where(.pull[data-n="drawer"]) {
      --x: 90;
      --y: 66;
      --w: 60;
      --h: 12;
    }

    & :where(.pull[data-n="cupboard"]) {
      --x: var(--pull-x, 194);
      --y: 152;
      --w: 12;
      --h: 72;
    }

    & :where(.slab) {
      --x: 0;
      --y: 0;
      --w: 240;
      --h: 24;
      --fill: var(--paint);
      --pattern: linear-gradient(transparent 0 62%, var(--chrome) 62%);

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

    &[data-hinge="right"] {
      --pull-x: 34;
    }
  }

  .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);
  }

  @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;
      }
    }
  }
}
