/*
  Colour grader — /studio/colour-grader/

  Ported from intsros/013/zygapp-colour-grader.html. The demo was a standalone
  page and owned its own background, body and container; on ZygApp it lives
  inside the public base template, so anything that would fight that template
  has been scoped or removed — the same treatment filter-rack.css got:

    * body background / font / colour  -> deleted, public.css owns them
    * .wrap, header, h1                -> renamed under .cgr so they cannot
                                          restyle the site nav or the footer
    * bare element selectors (button,
      input, details, pre)             -> scoped under .cgr

  Everything visual inside the grader itself is unchanged from the demo.
  Zero dependencies, no build step — same as the original.
*/

.cgr{
  --bg-0:#07101a; --bg-1:#0b1220;
  --panel:rgba(255,255,255,0.035); --panel-hi:rgba(255,255,255,0.06);
  --line:rgba(255,255,255,0.08); --line-hi:rgba(159,215,255,0.35);
  --ink:#e6eef6; --ink-2:#9fb8d8; --ink-3:#6b8099;
  --accent:#3aa0ff; --violet:#764ba2; --warn:#f0997b; --ok:#5dcaa5;
  --sans:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,monospace;
}
.cgr *{box-sizing:border-box}
.cgr{max-width:1100px;margin:0 auto;padding:32px 20px 40px}

/* ---------------------------------------------------------------------------
   THE STICKY VIEWER

   position: sticky on an INNER element, never a nested scroll container.

   The page keeps one natural scroll: the controls below scroll the document,
   not a box inside it. Giving them their own height + overflow:auto would
   produce a second scrollbar, kill momentum scrolling and the address-bar
   hide on mobile, and break anchor links — all to solve a problem sticky
   already solves while staying in normal flow.

   LOAD-BEARING CONSTRAINT: position:sticky fails SILENTLY if any ancestor of
   .cgr-viewer has overflow set to anything but visible. The chain here is
   .cgr -> main#main -> body -> html, and none of them do. Note that
   mobile-responsive.css sets `body { overflow-x: hidden }` — it is not loaded
   by base_public.html, which pulls public.css alone. If that ever changes,
   this pins nothing and nothing visibly errors.
--------------------------------------------------------------------------- */
.cgr-viewer{
  position:sticky; top:0; z-index:20;
  /* Opaque enough that controls scrolling underneath are properly hidden.
     Full-bleed across the container gutters so it reads as a bar, not a card. */
  background:rgba(7,16,26,.94);
  margin:0 -20px 0; padding:14px 20px 10px;
  border-bottom:1px solid var(--line);
  box-shadow:0 10px 24px -18px rgba(0,0,0,.9);
}
@supports (backdrop-filter:blur(8px)){
  .cgr-viewer{ background:rgba(7,16,26,.82); backdrop-filter:blur(12px) saturate(120%); }
}

.cgr-viewer-grid{
  display:grid;
  grid-template-columns:minmax(220px,290px) minmax(0,1fr);
  gap:22px; align-items:start;
}

.cgr-explain{ min-width:0; }
.cgr-explain h2{
  font-size:22px;font-weight:600;letter-spacing:-.01em;margin:0 0 10px;
  color:#cfe9ff;font-family:var(--sans);text-transform:none;
}
.cgr-explain p{ margin:0 0 10px;font-size:13px;line-height:1.65;color:var(--ink-3); }
.cgr-explain p:last-child{ margin-bottom:0; }
.cgr-explain b{ color:var(--ink-2);font-weight:600; }
.cgr-explain code{ font-family:var(--mono);font-size:12px;color:var(--ink-2); }
.cgr-eyebrow{
  font-family:var(--mono);font-size:10.5px;letter-spacing:.16em;
  text-transform:uppercase;color:var(--accent);margin:0 0 6px!important;
}

.cgr-screen{ min-width:0; }

/* Pushed right so it reads as a view control rather than another transport
   button. Hidden until JS reveals it — see the template. */
.cgr .cgr-toggle{
  margin-left:auto;font-size:13px;padding:8px 14px;
  color:var(--ink-3);background:transparent;
}
.cgr .cgr-toggle:hover:not(:disabled){ color:var(--ink-2); }

/* The toggle only ever affects the explainer. The privacy line lives in the
   screen column precisely so it cannot be collapsed away. */
.cgr[data-explain="off"] .cgr-explain{ display:none; }
.cgr[data-explain="off"] .cgr-viewer-grid{ grid-template-columns:minmax(0,1fr); }
.cgr[data-explain="on"] .cgr-explain{ display:block; }

.cgr-controls{ padding-top:22px; }

.cgr .stage{
  /* vh first as a fallback, then dvh so a mobile address bar appearing does
     not push the transport off screen. */
  --stage-cap:46vh;
  --stage-cap:46dvh;
  position:relative;border:1px solid var(--line);border-radius:14px;overflow:hidden;
  background:#04080f;margin:0 auto 10px;aspect-ratio:16/9;
  width:100%;max-width:calc(var(--stage-cap) * 16 / 9);
}
.cgr #gl,.cgr #vid{display:block;width:100%;height:100%;object-fit:cover}
.cgr #vid{display:none}
.cgr .overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:14px;text-align:center;padding:24px;color:var(--ink-2)}
.cgr .overlay p{margin:0;font-size:14px;line-height:1.6;max-width:38ch}

/* Left of the line is the UNGRADED source, right is graded. The labels say
   so, and the shader agrees — do not swap one without the other. */
.cgr .splitline{position:absolute;top:0;bottom:0;width:1px;background:rgba(255,255,255,.55);pointer-events:none;display:none}
.cgr .splitline::after{content:"BEFORE";position:absolute;top:10px;left:-62px;font-family:var(--mono);font-size:10px;letter-spacing:.1em;color:rgba(255,255,255,.75)}
.cgr .splitline::before{content:"AFTER";position:absolute;top:10px;left:8px;font-family:var(--mono);font-size:10px;letter-spacing:.1em;color:rgba(255,255,255,.75)}
.cgr .tag{position:absolute;top:12px;left:14px;font-family:var(--mono);font-size:11px;letter-spacing:.08em;color:rgba(255,255,255,.5);pointer-events:none}
.cgr .scopewrap{position:absolute;right:12px;bottom:12px;width:200px;height:74px;background:rgba(3,8,16,.72);border:1px solid rgba(255,255,255,.12);border-radius:8px;padding:5px;pointer-events:none}
.cgr #scope{width:100%;height:100%;display:block}

.cgr .transport{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-bottom:8px}
.cgr button{font-family:inherit;font-size:14px;color:var(--ink);background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:10px 16px;cursor:pointer;transition:background .15s,border-color .15s,transform .06s}
.cgr button:hover:not(:disabled){background:var(--panel-hi);border-color:var(--line-hi)}
.cgr button:active:not(:disabled){transform:translateY(1px)}
.cgr button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.cgr button[aria-pressed="true"]{background:linear-gradient(90deg,rgba(58,160,255,.22),rgba(118,75,162,.22));border-color:var(--line-hi);color:#eaf6ff}
.cgr button:disabled{opacity:.35;cursor:not-allowed}

.cgr .status{font-size:13px;color:var(--ink-2);margin:0;min-height:20px;line-height:1.5}
.cgr .status.warn{color:var(--warn)}
.cgr .status.ok{color:var(--ok)}

/* Limit notices sit next to the control they constrain, never in a help
   section, and never with an exclamation mark. */
.cgr .limit{font-size:12.5px;color:var(--ink-3);line-height:1.6;margin:0 0 18px;max-width:62ch}
.cgr .limit[hidden]{display:none}
.cgr .privacy{font-size:13.5px;color:var(--ink-2);line-height:1.65;margin:0 0 14px;max-width:60ch}
.cgr .privacy b{color:#cfe9ff;font-weight:600}

.cgr .chain{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:14px;margin-bottom:22px}
.cgr .mod{border:1px solid var(--line);border-radius:12px;padding:16px 16px 18px;background:var(--panel)}
.cgr .mod h3{margin:0 0 14px;font-size:12px;font-weight:600;letter-spacing:.1em;color:var(--ink-3);font-family:var(--mono);text-transform:uppercase}
.cgr .mod h3 b{color:var(--accent);font-weight:600;margin-right:8px}
.cgr .ctl{margin-bottom:13px}
.cgr .ctl:last-child{margin-bottom:0}
.cgr .ctl label{display:flex;justify-content:space-between;align-items:baseline;font-size:13px;color:var(--ink-2);margin-bottom:6px}
.cgr .ctl output{font-family:var(--mono);font-size:13px;color:#cfe9ff}
.cgr input[type=range]{-webkit-appearance:none;appearance:none;width:100%;height:20px;background:transparent;cursor:pointer;margin:0}
.cgr input[type=range]::-webkit-slider-runnable-track{height:3px;background:rgba(255,255,255,.12);border-radius:2px}
.cgr input[type=range]::-moz-range-track{height:3px;background:rgba(255,255,255,.12);border-radius:2px}
.cgr input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:15px;height:15px;border-radius:50%;margin-top:-6px;background:linear-gradient(180deg,#7fc4ff,var(--accent));border:none}
.cgr input[type=range]::-moz-range-thumb{width:15px;height:15px;border-radius:50%;border:none;background:var(--accent)}
.cgr input[type=range]:focus-visible{outline:2px solid var(--accent);outline-offset:4px;border-radius:4px}

.cgr .presets{border-top:1px solid var(--line);padding-top:20px;margin-bottom:20px}
.cgr .presets h3{font-size:13px;font-weight:500;color:var(--ink-2);margin:0 0 12px}
.cgr .chips{display:flex;flex-wrap:wrap;gap:8px}
.cgr .chips button{padding:8px 14px;font-size:13px;border-radius:20px}

/* LUT selector. Renders only when there is something in it — the section is
   omitted server-side otherwise, not hidden with CSS. */
.cgr .luts{border-top:1px solid var(--line);padding-top:20px;margin-bottom:20px}
.cgr .luts h3{font-size:13px;font-weight:500;color:var(--ink-2);margin:0 0 12px}
.cgr .lut-credit{font-size:12.5px;color:var(--ink-3);margin:10px 0 0;line-height:1.6}
.cgr .lut-credit[hidden]{display:none}
.cgr .lut-credit a{color:var(--ink-2)}
.cgr .creator-chip{border-color:rgba(159,215,255,.22)}

.cgr .exportrow{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-bottom:8px}

.cgr .note{font-size:13px;color:var(--ink-3);line-height:1.7;margin:22px 0 0;max-width:66ch}
.cgr .note code{font-family:var(--mono);font-size:12px;color:var(--ink-2)}

/* No WebGL: the tool is inert but the page is not. Nothing is hidden, so a
   reader still gets every explanatory sentence on the page. */
.cgr.no-webgl .stage{opacity:.45}
.cgr.no-webgl .chain,.cgr.no-webgl .presets,.cgr.no-webgl .luts{opacity:.55}

/* ---------------------------------------------------------------------------
   THE INTRO, KEPT SHORT

   `section { padding: 56px 0 }` in public.css plus three paragraphs of lede
   put the screen below the fold, which on a grading tool is the whole
   product below the fold. This trims the header to an eyebrow, a title and
   one line, and the rest of the copy moved underneath the tool.

   The budget: site nav ~70px + this header ~110px leaves the stage starting
   around 180px down, so 46dvh of picture is fully visible on anything taller
   than about 560px.
--------------------------------------------------------------------------- */
.cgr-intro{ padding:30px 0 0; border-top:0; }
.cgr-title{
  margin:0 0 10px; font-size:clamp(1.7rem,4vw,2.3rem);
  letter-spacing:-.02em; line-height:1.1;
}
.cgr-standfirst{
  max-width:62ch; margin:0; font-size:1.02rem; line-height:1.6;
  color:var(--text-dim,#9fb8d8);
}
.cgr-standfirst strong{ color:#cfe9ff; font-weight:600; }
.cgr-standfirst code{
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size:.92em; color:#9fd7ff;
}
@media (max-width:560px){
  .cgr-intro{ padding:20px 0 0; }
  .cgr-standfirst{ font-size:.95rem; }
}
/* Landscape phones: every pixel of height belongs to the picture. */
@media (max-height:540px){
  .cgr-intro{ padding:14px 0 0; }
  .cgr-standfirst{ display:none; }
}

/* ---------------------------------------------------------------------------
   GEAR AND LISTINGS

   Same card treatment as the filter rack's .frk-more-grid, on purpose. Two
   Studio tools that list the same kinds of thing should not look like two
   different products because one of them got a bare <ul>.
--------------------------------------------------------------------------- */
.cgr-gear{
  max-width:66ch; margin:34px 0 0; padding-top:22px;
  border-top:1px solid rgba(255,255,255,0.08);
  font-size:15px; line-height:1.65;
}
.cgr-gear .cgr-disclosure{ font-size:13px; color:#6b8099; margin:0 0 10px; }
.cgr-gear p{ margin:0 0 10px; }
.cgr-gear a{ color:#7aa2ff; }

.cgr-more{
  max-width:66ch; margin:38px 0 0; padding-top:24px;
  border-top:1px solid rgba(255,255,255,0.08);
}
.cgr-more h2{
  font-size:19px; font-weight:600; color:#cfe9ff;
  margin:0 0 6px; letter-spacing:-.01em;
}
.cgr-more-lead{ font-size:14px; color:#6b8099; margin:18px 0 10px; }
.cgr-more-grid{
  list-style:none; margin:0; padding:0;
  display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:10px;
}
.cgr-more-grid li{ margin:0; }
.cgr-more-grid a{
  display:block; height:100%; text-decoration:none;
  border:1px solid rgba(255,255,255,0.08); border-radius:11px;
  background:rgba(255,255,255,0.025); padding:13px 15px;
  transition:border-color .15s, background .15s;
}
.cgr-more-grid a:hover{
  border-color:rgba(159,215,255,0.3); background:rgba(255,255,255,0.05);
}
/* Tag as a small label ABOVE the name, each on its own line — run together
   they read as one garbled string, which is how this landed on the rack. */
.cgr-more-tag{
  display:block; font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size:10.5px; letter-spacing:.09em; text-transform:uppercase;
  color:#6b8099; margin-bottom:5px;
}
.cgr-more-name{
  display:block; font-size:14.5px; line-height:1.45; color:#cfe9ff;
  font-weight:500;
}
.cgr-more-foot{ margin:20px 0 0; font-size:14px; color:#6b8099; line-height:1.8; }
.cgr-more-foot a{ color:#7aa2ff; text-decoration:none; }
.cgr-more-foot a:hover{ text-decoration:underline; }

/* Creator contribution invitation. Only rendered when both switches are on —
   see the template. */
.cgr-contribute{
  border:1px solid rgba(159,215,255,.18);border-radius:12px;
  padding:18px 20px;margin-top:26px;background:rgba(58,160,255,.04);
}
.cgr-contribute h3{margin:0 0 10px;font-size:16px;color:#cfe9ff;font-weight:600}
.cgr-contribute p{margin:0 0 10px;font-size:14px;line-height:1.7;color:var(--ink-2);max-width:62ch}
.cgr-contribute p:last-child{margin-bottom:0}
.cgr-contribute b{color:#cfe9ff;font-weight:600}
.cgr-contribute code{font-family:var(--mono);font-size:12.5px;color:var(--ink-2)}
.cgr-contribute-note{font-size:13.5px!important;color:var(--ink-3)!important}
.cgr-contribute-cta{color:var(--accent);text-decoration:none;font-weight:600;font-size:14px}
.cgr-contribute-cta:hover{text-decoration:underline}

/* Touch. This is a tool driven almost entirely by dragging eleven sliders,
   so the thumb is the control that matters: 15px is a fiddly target with a
   fingertip, and a missed grab on a grading slider means a wrong value
   rather than nothing happening. Pointer-based, not width-based — a touch
   laptop needs this and a narrow desktop window does not. */
@media (pointer:coarse){
  .cgr button{ min-height:40px; }
  .cgr input[type=range]{ height:30px; }
  .cgr input[type=range]::-webkit-slider-thumb{
    width:22px;height:22px;margin-top:-9.5px;
  }
  .cgr input[type=range]::-moz-range-thumb{ width:22px;height:22px; }
  .cgr .ctl{ margin-bottom:16px; }
}

@media (prefers-reduced-motion:reduce){.cgr *{transition:none!important}}

/* ---------------------------------------------------------------------------
   RESPONSIVE

   One thing governs all of it: the screen has to stay visible while the
   controls are being worked, on every size of display. So the height budget
   shrinks as the viewport does, and the explainer — which is context, not
   instrumentation — is the first thing to go.

   The cap is applied to the stage's WIDTH (max-width: cap * 16/9) rather than
   its height. Capping height against a fixed aspect-ratio box makes the box
   stop being 16:9, and the shader maps the source across the whole quad, so
   the picture would stretch rather than letterbox.
--------------------------------------------------------------------------- */

/* Tablet and small laptops: keep them side by side, give the screen more. */
@media (max-width:1023px){
  .cgr-viewer-grid{grid-template-columns:minmax(190px,240px) minmax(0,1fr);gap:18px}
  .cgr .stage{--stage-cap:42vh;--stage-cap:42dvh}
  .cgr-explain h2{font-size:20px}
}

/* Below this the two columns stop being worth it: a 200px explainer beside a
   200px picture serves neither. Single column, and the explainer is out of
   the pinned bar's way unless someone asks for it. */
@media (max-width:859px){
  .cgr-viewer-grid{grid-template-columns:minmax(0,1fr);gap:14px}
  .cgr-explain{display:none}
  /* Toggled on by hand: capped and scrollable so it can never push the
     transport off the screen. */
  .cgr[data-explain="on"] .cgr-explain{max-height:24vh;max-height:24dvh;overflow:auto}
  .cgr .stage{--stage-cap:36vh;--stage-cap:36dvh}
  .cgr .chain{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px}
}

@media (max-width:560px){
  .cgr{padding:20px 16px 32px}
  .cgr-viewer{margin-inline:-16px;padding:12px 16px 8px}
  .cgr-explain h2{font-size:19px}
  .cgr .stage{--stage-cap:32vh;--stage-cap:32dvh}
  .cgr .scopewrap{width:112px;height:48px;right:8px;bottom:8px}
  .cgr .transport{gap:8px}
  .cgr button{padding:9px 13px;font-size:13.5px}
  .cgr .cgr-toggle{margin-left:0}
}

/* Landscape phones and short windows. There is not enough height here to give
   any of it to prose, and a 46dvh picture would leave no room for a slider. */
@media (max-height:540px){
  .cgr-explain{display:none}
  .cgr[data-explain="on"] .cgr-explain{display:none}
  .cgr-viewer{padding-block:8px 6px}
  .cgr .stage{--stage-cap:54vh;--stage-cap:54dvh;margin-bottom:8px}
  .cgr .scopewrap{width:112px;height:48px}
}
