/* Page-specific styles for Canon Component Library. Loaded after the shared CSS. */

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/JetBrainsMono-Regular.woff2") format("woff2");
}

/* Visuals with short captions, below the intro (same as the other work pages).
   48px between every section, the same rhythm as hero → intro. */
.shots {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  margin-top: var(--space-12);
}

/* An 8px matte in the placeholder tone around each image (960 → 944 × 531) */
.shot__media {
  padding: var(--space-2);
  background: var(--media-placeholder);
}

.shot__media > img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.shot figcaption {
  max-width: var(--col-text); /* 544, same measure as the intro */
  margin-top: var(--space-4);
  padding-inline: var(--text-inset);
  color: var(--text-secondary);
}

.shot__title {
  font-weight: 600;
  color: var(--text-primary);
}

/* Live demos ----------------------------------------------------------------
   A Canon page in an iframe (its own stylesheet, so Canon and this site never
   touch), the switches above it and the markup below, all inside the matte. */
.demo__media {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* The height follows the frame's content (script.js); this is the size before it loads */
.demo__frame {
  display: block;
  width: 100%;
  height: 24rem;
  border: 0;
  background: var(--bg-main);
}

.demo__code {
  margin: 0;
  padding: var(--space-4);
  overflow-x: auto;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;   /* 13px */
  line-height: 1.25rem;   /* 20px */
  color: var(--text-secondary);
  background: var(--bg-sidebar);  /* the sidebar's colour: white in light mode, moss-950 in dark */
  tab-size: 2;
}
.demo__code:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: -2px;
}

/* Inline code in captions */
.shot figcaption code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.875em;
}

/* Closing: a short paragraph, then the two install lines in a matte */
.closing__text {
  max-width: var(--col-text);
  margin-bottom: var(--space-4);
  padding-inline: var(--text-inset);
  color: var(--text-secondary);
}

/* Syntax colours in the code panels */
.demo__code {
  --t-tag: var(--link);
  --t-attr: #7c3aed;    /* violet-600, 5.4:1 on the page */
  --t-string: #047857;  /* emerald-700, 5.2:1 */
}
:root[data-theme="dark"] .demo__code {
  --t-attr: #c4b5fd;    /* violet-300 */
  --t-string: var(--emerald-400);
}
.t-p { color: var(--text-secondary); }
.t-t { color: var(--t-tag); }
.t-a { color: var(--t-attr); }
.t-s { color: var(--t-string); }

/* The caret while an attribute is typed in */
.pg-caret {
  color: var(--bg-main);
  background: var(--text-primary);
}

/* Button playground ----------------------------------------------------------
   Controls and preview side by side when there's room, stacked on phones.
   Each control writes one attribute; script.js types it into the markup. */
.pg {
  display: grid;
  gap: var(--space-2);
}
@container (min-width: 40em) {
  .pg {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.pg__controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6);
  background: var(--bg-main);
}
.pg__controls[hidden] {
  display: none;
}

.pg__row {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.pg__attr {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  line-height: 1.25rem;
  color: var(--text-secondary);
}
/* Label and options side by side. The legend floats in a fixed label column (a legend can't be a
   grid or flex item), centred on the 44px track; the track, a grid, keeps clear of the float and
   takes the rest of the row. The Theme label uses the same column, so the select lines up too. */
.pg {
  --pg-label: 6rem;
}
.pg__row > legend {
  float: left;
  width: var(--pg-label);
  padding: 0;
  line-height: 2.75rem;
}
/* A label brightens once its control leaves where it started (:default is the option checked in
   the markup: Medium, no intent, switches off) */
.pg__row:has(input:checked:not(:default)) > legend,
.pg__switch-row:has(:checked) > .pg__attr {
  color: var(--text-primary);
}

/* Four options in a recessed track; the chosen one on a raised plate */
.pg__tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  background: var(--media-placeholder);
}
.pg__option {
  position: relative;
  display: grid;
  place-items: center;
  height: 2.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.pg__option:hover {
  color: var(--text-primary);
}
.pg__option:has(:checked) {
  color: var(--text-primary);
  background: var(--bg-main);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);
}
/* Light mode: a grey track and a white plate with an edge, so the choice reads at a glance
   (the dark scheme's lighter track and darker plate already do) */
:root:not([data-theme="dark"]) .pg__tiles {
  background: var(--moss-50);
}
:root:not([data-theme="dark"]) .pg__option:has(:checked) {
  background: var(--white);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.14);
}
.pg__option > input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.pg__option:has(:focus-visible) {
  outline: 2px solid var(--link);
  outline-offset: -2px;
}

/* Keyboard only, like the site's other rings (base.css) */
:root[data-input="pointer"] .pg__option:has(:focus-visible) {
  outline: none;
}

/* Meanings: Canon's own colours, light and dark. No intent is Canon's blue. --pg-solid is the
   600 shade a high-emphasis button fills with in both schemes, so the chosen pill matches it. */
.pg {
  --pg-blue: #2563eb;
  --pg-success: #16a34a;
  --pg-warning: #d97706;
  --pg-danger: #dc2626;
  --pg-tone: var(--pg-blue);
  --pg-solid: #2563eb;
}
:root[data-theme="dark"] .pg {
  --pg-blue: #60a5fa;
  --pg-success: #4ade80;
  --pg-warning: #fbbf24;
  --pg-danger: #f87171;
}
.pg[data-tone="success"] { --pg-tone: var(--pg-success); --pg-solid: #16a34a; }
.pg[data-tone="warning"] { --pg-tone: var(--pg-warning); --pg-solid: #d97706; }
.pg[data-tone="danger"] { --pg-tone: var(--pg-danger); --pg-solid: #dc2626; }

/* Emphasis: a tiny button at each level, grey until chosen, then in the meaning's colour */
.pg__pill {
  --_t: var(--text-secondary);
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 1.75rem;
  height: 0.875rem;
  border-radius: 0.25rem;
  color: var(--_t);
}
.pg__option:has(:checked) > .pg__pill { --_t: var(--pg-tone); }
.pg__pill::after {
  content: "";
  width: 0.75rem;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}
.pg__pill[data-emphasis="high"] { background: var(--_t); color: var(--bg-main); }
.pg__option:has(:checked) > .pg__pill[data-emphasis="high"] { background: var(--pg-solid); color: #fff; }
.pg__pill[data-emphasis="medium"] { background: color-mix(in srgb, var(--_t) 22%, transparent); }
.pg__pill[data-emphasis="low"] { border: 1px solid color-mix(in srgb, var(--_t) 45%, transparent); }

/* Intent: an icon each, grey until chosen; "none" a dashed ring */
.pg__glyph {
  width: 1.125rem;
  height: 1.125rem;
  background: currentColor;
  -webkit-mask: var(--_icon) center / contain no-repeat;
  mask: var(--_icon) center / contain no-repeat;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.pg__option:has(:checked) > .pg__glyph { background: var(--_tone); }
.pg__option[data-tone="auto"] { --_tone: var(--text-primary); --_icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-dasharray='3.5 3'><circle cx='12' cy='12' r='9'/></svg>"); }
.pg__option[data-tone="success"] { --_tone: var(--pg-success); --_icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='m8.5 12.5 2.5 2.5 5-6'/></svg>"); }
.pg__option[data-tone="warning"] { --_tone: var(--pg-warning); --_icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z'/><path d='M12 9v4M12 17h.01'/></svg>"); }
.pg__option[data-tone="danger"] { --_tone: var(--pg-danger); --_icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 8v4M12 16h.01'/></svg>"); }

/* The two switches on one line */
.pg__pair {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end; /* both switches at the end, the last where the tracks and the select end */
  gap: var(--space-4) var(--space-8);
}
.pg__switch-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}
.pg__switch {
  appearance: none;
  position: relative;
  width: 2.25rem;
  height: 1.25rem;
  margin: 0;
  border-radius: 999px;
  background: var(--media-placeholder);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.pg__switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: translate var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.pg__switch:checked {
  background: var(--text-primary);
  box-shadow: none;
}
.pg__switch:checked::after {
  translate: 1rem 0;
  background: var(--bg-main);
}
.pg__switch:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* Theme: a label and a native select */
.pg__select-row {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
}
.pg__select-row > span {
  flex: none;
  width: var(--pg-label);
}
.pg__select-row > select {
  flex: 1;
  min-width: 0;
  height: 2.5rem;
  padding-inline: 0.875rem 2.75rem;  /* text 14px in, like the chevron from the other side */
  font: 0.8125rem/1.25rem "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-primary);
  /* Our own chevron, inset like the text (the native one hugs the edge); text-secondary per theme */
  appearance: none;
  background: var(--media-placeholder) no-repeat right 0.875rem center / 1rem
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371716e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  border: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
}
:root[data-theme="dark"] .pg__select-row > select {
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d1cfcb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
}
.pg__select-row > select:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 1px;
}

/* The preview: the button alone, in its theme */
.pg__preview {
  display: block;
  width: 100%;
  min-height: 14rem;
  height: 100%;
  box-sizing: border-box;
  border: 0;
  background: var(--bg-main);
}
/* Light mode: Canon's white page needs an edge against the white matte */
:root:not([data-theme="dark"]) .pg__preview {
  border: 1px solid var(--border);
}

/* While an attribute is being typed, the controls wait */
.demo[data-typing] .pg__controls {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .pg__option,
  .pg__switch,
  .pg__switch::after,
  .pg__glyph {
    transition: none;
  }
}

/* The button's opening tag wraps between its attributes instead of scrolling */
[data-demo="button"] .demo__code {
  white-space: pre-wrap;
}
[data-demo="button"] .demo__code :is(.t-s, .t-a):not(.t-url) {
  white-space: nowrap; /* never break inside a name or a value (at its hyphens) */
}

/* Phones: every code panel wraps instead of scrolling sideways (between attributes,
   never inside a name or value; a long URL may break anywhere) */
@media (max-width: 44.99em) {
  .demo__code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .demo__code :is(.t-s, .t-a):not(.t-url) {
    white-space: nowrap;
  }
}

/* A video in the matte: poster on top until the video plays (same layering as .media heroes) */
.shot__video {
  aspect-ratio: 16 / 9;
}

.shot__video > video {
  position: absolute;
  inset: 0;
}

/* The live film (demos/detail.html): an SVG drawing in a frame, played by script.js like the video.
   Clicks go to the box (the play button, or a tap to pause), not into the frame. */
.shot__live > iframe {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  border: 0;
  display: block;
  pointer-events: none;
  background: #1f347a;
}

/* Play button (touch screens, reduced motion): the shared .video-play style, hidden while playing */
.shot__video.is-manual .video-play {
  display: grid;
}

.shot__video.is-active .video-play {
  opacity: 0;
  pointer-events: none;
}
