/* Pack editor: the "editeur" section of the Unisson model, its rules carried over to the shadow tree.
   Colours come from the --pack-* tokens only. The editor's accent is a formula, not a palette colour: a fixed
   lightness and chroma (--editor-l, --editor-c, plain numbers) at the hue of the slider. The hue ramp of the slider
   is that same formula at seven hues, so it shows exactly the accents the preview can take. */
:host {
  display: block;
  min-inline-size: 0;
  --editor-mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --editor-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* The accent of the dark scheme, also what the export writes. */
  --editor-l: 0.78;
  --editor-c: 0.14;
  /* The accent of the light scheme (the model's light theme). */
  --editor-light-l: 0.58;
  --editor-light-c: 0.2;
  /* White in both schemes (the slider thumb): the light button ink is white, the dark ink is near white. */
  --editor-white: light-dark(var(--pack-btnink), var(--pack-ink));
  color: var(--pack-ink);
  font: 16px / 1.6 var(--editor-sans);
  letter-spacing: normal;
  -webkit-font-smoothing: antialiased;
}
:host([hidden]) {
  display: none;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
h2,
h3,
p {
  margin: 0;
}
:focus-visible {
  outline: 2px solid var(--pack-focus);
  outline-offset: 3px;
  border-radius: 6px;
}

[part="section"] {
  padding-block: 84px 0;
}
[part="container"] {
  inline-size: min(1200px, 100% - 32px);
  margin-inline: auto;
}
[part="head"] {
  margin-block-end: 34px;
}
[part="kicker"] {
  font: 700 12px var(--editor-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pack-link);
}
[part="heading"] {
  margin-block-start: 10px;
  font: 800 clamp(30px, 4.4vw, 48px) / 1.1 var(--editor-sans);
  letter-spacing: -0.035em;
}
[part="lead"] {
  margin-block-start: 14px;
  max-inline-size: 64ch;
  color: var(--pack-mut);
  font-size: 17px;
}

/* The glowing frame (.ed.glow). The ring is a mask: its colour only lends its opacity. */
[part="editor"] {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 22px;
  padding: 24px;
  border-radius: 18px;
  background: var(--pack-panel);
  border: 1px solid var(--pack-line);
  box-shadow: var(--pack-shadow);
}
[part="editor"]::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, var(--pack-c1), transparent 35%, transparent 65%, var(--pack-c2));
  opacity: 0.55;
  pointer-events: none;
  -webkit-mask:
    linear-gradient(var(--pack-ink) 0 0) content-box,
    linear-gradient(var(--pack-ink) 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(var(--pack-ink) 0 0) content-box exclude,
    linear-gradient(var(--pack-ink) 0 0);
}

[part="controls"] {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
[part="label"] {
  display: flex;
  justify-content: space-between;
  font: 600 13px var(--editor-mono);
  margin-block-end: 6px;
}
[part="value"] {
  color: var(--pack-link);
}
/* The model's heights: the catalogue's touch minimum on range inputs is lifted. */
input[type="range"] {
  inline-size: 100%;
  min-block-size: 0;
  block-size: 28px;
  accent-color: var(--pack-c2);
  cursor: pointer;
  background: transparent;
}
input.hue {
  appearance: none;
  -webkit-appearance: none;
  block-size: 12px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    oklch(var(--editor-l) var(--editor-c) 0),
    oklch(var(--editor-l) var(--editor-c) 60),
    oklch(var(--editor-l) var(--editor-c) 120),
    oklch(var(--editor-l) var(--editor-c) 180),
    oklch(var(--editor-l) var(--editor-c) 240),
    oklch(var(--editor-l) var(--editor-c) 300),
    oklch(var(--editor-l) var(--editor-c) 360)
  );
}
input.hue::-webkit-slider-thumb {
  -webkit-appearance: none;
  inline-size: 22px;
  block-size: 22px;
  border-radius: 50%;
  background: var(--editor-white);
  border: 3px solid var(--pack-ink);
  box-shadow: 0 0 14px var(--pack-a2);
}
input.hue::-moz-range-thumb {
  inline-size: 18px;
  block-size: 18px;
  border-radius: 50%;
  background: var(--editor-white);
  border: 3px solid var(--pack-ink);
}

/* The export (.proof.exp). */
[part="export"] {
  margin-block-start: 4px;
  border-radius: 10px;
  border: 1px solid var(--pack-line);
  background: var(--pack-code);
  overflow: hidden;
}
[part="export-caption"] {
  padding: 5px 12px;
  border-block-end: 1px solid var(--pack-line);
  font: 600 11px var(--editor-mono);
  color: var(--pack-mut);
}
pre {
  margin: 0;
  padding: 12px;
  font: 12px / 1.6 var(--editor-mono);
  color: var(--pack-codeink);
  overflow: auto;
}

/* The recoloured preview (.prev): the only element that turns the settings into colour and radius. */
[part="preview"] {
  --hue: var(--editor-hue, 295);
  --rad: var(--editor-radius, 12px);
  --ac: light-dark(oklch(var(--editor-light-l) var(--editor-light-c) var(--hue)), oklch(var(--editor-l) var(--editor-c) var(--hue)));
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border-radius: calc(var(--rad) + 6px);
  background: light-dark(var(--pack-btnink), var(--pack-code));
  border: 1px solid var(--pack-line2);
  color: var(--pack-codeink);
  box-shadow: 0 0 60px -20px var(--ac);
}
[part="preview-heading"] {
  font: 700 18px var(--editor-sans);
  color: var(--pack-ink);
}
[part="row"] {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  color: var(--pack-ink);
}
[part="switch"] {
  position: relative;
  flex: none;
  inline-size: 46px;
  block-size: 26px;
  border-radius: var(--rad);
  background: var(--ac);
  box-shadow: 0 0 18px -2px var(--ac);
}
[part="switch"]::after {
  content: "";
  position: absolute;
  inset-block-start: 3px;
  inset-inline-end: 3px;
  inline-size: 20px;
  block-size: 20px;
  border-radius: min(var(--rad), 10px);
  background: var(--pack-btnink);
}
[part="badge"] {
  padding: 3px 10px;
  border-radius: var(--rad);
  border: 1px solid var(--ac);
  font: 700 12px var(--editor-sans);
  color: var(--pack-ink);
}
[part="gauge"] {
  block-size: 10px;
  border-radius: var(--rad);
  background: color-mix(in oklch, color-mix(in oklch, var(--pack-mut) 60%, var(--pack-bg)) 25%, transparent);
  overflow: hidden;
}
[part="gauge"] i {
  display: block;
  inline-size: var(--editor-usage, 68%);
  block-size: 100%;
  background: var(--ac);
}
[part="button"] {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-block-size: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--rad);
  background: var(--ac);
  color: var(--pack-btnink);
  font: 700 15px var(--editor-sans);
  cursor: default;
}

@media (max-width: 980px) {
  [part="editor"] {
    grid-template-columns: 1fr;
  }
}
/* Under 390 px the export's longest code line would widen the frame past the page: the column may shrink below it,
   and the line scrolls in its pre. From 390 px the frame keeps the model's width. */
@media (max-width: 389px) {
  [part="editor"] {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 700px) {
  [part="section"] {
    padding-block-start: 64px;
  }
}

/* Forced colours: the ramp and the accent fills are dropped, the frame and the preview keep system outlines. */
@media (forced-colors: active) {
  [part="editor"]::after {
    display: none;
  }
  input.hue {
    border: 1px solid CanvasText;
  }
  [part="preview"],
  [part="switch"],
  [part="gauge"],
  [part="button"] {
    border: 1px solid CanvasText;
  }
  [part="gauge"] i {
    background: Highlight;
    forced-color-adjust: none;
  }
}
