/* Plugins section (plugins.html + sdui.html), layered on style.css + content.css.
   Inherits the site world; adds an editor's vocabulary drawn in it: ruler, V/A tracks,
   clips, a white playhead. Radius rule: large surfaces use --radius, clips and nav 10px,
   actions and chips are full pills. */

.plugin-page {
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ink: #f0efed;
  --clip: #26262b;
  --clip-audio: #1c2626;
  --clip-hi: #34343b;
  --wrap: 1320px;
  scrollbar-color: #2e2e2e #141414;
}

.plugin-page ::selection { background: rgba(240, 239, 237, 0.9); color: #141414; }

.plugin-page :focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 10px;
}

.plugin-page kbd,
.plugin-page code,
.plugin-page .path {
  font-family: var(--mono);
  font-size: 0.86em;
}

.plugin-page kbd {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  color: var(--ink);
  line-height: 1.5;
}

.plugin-page .path { color: var(--ink); white-space: nowrap; }

.plugin-page .content-page > section,
.plugin-page .content-page > .plugin-list {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
}

/* sections breathe; more air above a heading than below it */
.p-tools,
.p-install,
.p-facts,
.p-close { margin-top: clamp(56px, 10vh, 128px); }

.p-section-head h2,
.p-facts-title,
.p-close h2 {
  font-size: clamp(26px, 2.6vw, 40px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-wrap: balance;
}

.p-section-head p,
.p-close p {
  margin-top: 10px;
  max-width: 62ch;
  font-size: clamp(15px, 1.15vw, 18px);
  line-height: 1.55;
  color: var(--text-mid);
}

/* ---------------- first viewport ---------------- */

.p-hero {
  --film-w: min(100%, calc((100dvh - 300px) * 16 / 9));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(18px, 2.6vh, 30px);
}

.p-film {
  position: relative;
  width: var(--film-w);
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0e0e0e;
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.85);
}

.p-film-video { display: block; width: 100%; height: 100%; object-fit: cover; }

/* the one blurred control: it has to stay legible over moving footage */
.p-sound {
  position: absolute;
  right: clamp(10px, 1.4vw, 18px);
  bottom: clamp(10px, 1.4vw, 18px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 11px;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(18, 18, 18, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font: 500 13px/1 "Google Sans Flex", sans-serif;
  cursor: pointer;
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}

.p-sound:hover { background: rgba(38, 38, 38, 0.8); transform: translateY(-2px); }
.p-sound:active { transform: translateY(1px); }
.p-sound .p-sound-on,
.p-sound[aria-pressed="true"] .p-sound-off { display: none; }
.p-sound[aria-pressed="true"] .p-sound-on { display: block; }

.p-intro {
  width: var(--film-w);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.p-intro h1 {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: clamp(40px, 4.4vw, 66px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

.p-status {
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-mid);
}

.p-intro p {
  margin-top: 12px;
  max-width: 46ch;
  font-size: clamp(15px, 1.2vw, 19px);
  line-height: 1.5;
  color: var(--text-mid);
}

.p-download {
  flex: none;
  display: grid;
  grid-template-areas: "icon label" "icon meta";
  align-items: center;
  column-gap: 12px;
  padding: 14px 30px 14px 22px;
  border-radius: 50px;
  background: var(--ink);
  color: #141414;
  text-decoration: none;
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.7);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.2s ease;
}

.p-download img { grid-area: icon; filter: invert(1); }
.p-download span { grid-area: label; font-size: 17px; font-weight: 600; white-space: nowrap; }
.p-download small { grid-area: meta; font-size: 12.5px; font-weight: 500; color: rgba(20, 20, 20, 0.58); }
.p-download:hover { transform: translateY(-3px); background: #fff; box-shadow: 0 20px 36px -16px rgba(0, 0, 0, 0.8); }
.p-download:active { transform: translateY(1px); }

/* ---------------- tools: plain list (mobile, no JS) ---------------- */

.tl-stage { display: none; }

.tools {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  gap: 16px;
  margin-top: 28px;
  counter-reset: none;
}

.tool {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  overflow: hidden;
}

.tool-demo { aspect-ratio: 820 / 560; background: #151515; }
.tool-demo video { display: block; width: 100%; height: 100%; object-fit: cover; }

.tool-body { padding: 20px 22px 24px; }

.tool h3,
.mon-text h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.tool h3 img,
.mon-text h3 img { width: 28px; height: 28px; }

.tool p,
.mon-text > p {
  margin-top: 12px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-mid);
}

.tool-how {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 15px;
  color: var(--ink);
}

.tool-how li {
  position: relative;
  padding-left: 30px;
  counter-increment: how;
}

/* ordered steps: real numerals in the timecode face */
.tool-how { counter-reset: how; list-style: none; }

.tool-how li::before {
  content: counter(how);
  position: absolute;
  left: 0;
  top: 0.12em;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
}

.tool-note {
  margin-top: 16px !important;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 14px !important;
  color: var(--text-dim) !important;
}

/* ---------------- tools: scroll-scrubbed timeline (desktop) ---------------- */

.has-stage .tl-scroll {
  display: grid;
  margin-top: 28px;
  view-timeline: --tools block;
}

.has-stage .tl-stage,
.has-stage .tools { grid-area: 1 / 1; }

.has-stage .tools {
  display: block;
  margin: 0;
  padding: 50vh 0;
  pointer-events: none;
}

/* The list items become invisible, equal scroll steps; the stage shows them.
   Half-viewport padding on both ends makes the scroll-timeline progress land
   inside clip i exactly while step i crosses the viewport's middle line. */
.has-stage .tool {
  height: 56vh;
  visibility: hidden;
  border: 0;
}

.has-stage .tl-stage {
  position: sticky;
  top: 0;
  z-index: 1;
  align-self: start;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: clamp(12px, 2.2vh, 26px) 0;
}

.mon {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(22px, 3vw, 48px);
  padding: clamp(14px, 1.6vw, 22px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
}

/* sized by its content: the loop's own 820:560 frame, capped so monitor and
   timeline always fit one viewport together */
.mon-demo {
  position: relative;
  width: 100%;
  aspect-ratio: 820 / 560;
  max-height: calc(100dvh - 360px);
  border-radius: calc(var(--radius) - 8px);
  overflow: hidden;
}

.mon-demo video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  /* feather the loop's edges into the monitor: loop grounds vary (18-28 L), so a
     hard edge always shows as a seam */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent), linear-gradient(180deg, transparent, #000 7%, #000 93%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent), linear-gradient(180deg, transparent, #000 7%, #000 93%, transparent);
  mask-composite: intersect;
}

.mon-demo video.is-on { opacity: 1; }

.mon-text {
  align-self: center;
  max-width: 50ch;
  padding-right: clamp(0px, 2vw, 32px);
}

.mon-text h3 { font-size: clamp(26px, 2.4vw, 38px); gap: 14px; }
.mon-text h3 img { width: 36px; height: 36px; }
.mon-text > p { font-size: clamp(16px, 1.2vw, 19px); }
.mon-text .tool-how { font-size: clamp(15px, 1.05vw, 17px); }

.mon-text.is-swapping { animation: monSwap 0.42s var(--ease); }

@keyframes monSwap {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* timeline strip */
.tl {
  position: relative;
  padding: 10px 14px 12px 0;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #121212;
  font-family: var(--mono);
}

.tl-grid {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  row-gap: 5px;
}

.tl-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-faint);
}

.tl-ruler {
  position: relative;
  height: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tl-ruler i {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 4px;
  background: rgba(255, 255, 255, 0.16);
}

.tl-ruler i.big { height: 8px; background: rgba(255, 255, 255, 0.3); }

.tl-ruler b {
  position: absolute;
  top: 0;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-faint);
  transform: translateX(5px);
}

.tl-lane { position: relative; height: 32px; }

.clip {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 7px 0 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--clip);
  color: var(--text-dim);
  font: 500 12px/1 "Google Sans Flex", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease);
}

.clip img { width: 16px; height: 16px; flex: none; opacity: 0.8; }
.clip span { overflow: hidden; text-overflow: ellipsis; }
.clip.is-audio { background: var(--clip-audio); }
.clip:hover { color: var(--ink); background: var(--clip-hi); }
.clip.is-audio:hover { background: #243232; }

.clip.is-active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.95);
  background: var(--clip-hi);
}

.clip.is-active img { opacity: 1; }

/* playhead: the rail spans the lanes; scroll moves it (CSS scroll timeline where
   supported, otherwise JS snaps it to the active clip) */
.ph-rail {
  position: absolute;
  top: 10px;
  bottom: 12px;
  left: 52px;
  right: 14px;
  pointer-events: none;
}

.ph {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  transform: translateX(var(--ph-x, 4.5%));
  transition: transform 0.5s var(--ease);
}

.ph::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

.ph-flag {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(6px);
  padding: 2px 7px;
  border-radius: 4px;
  background: #fff;
  color: #141414;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
}

.ph.flag-left .ph-flag { transform: translateX(calc(-100% - 6px)); }

@supports (animation-timeline: view()) {
  .has-stage .ph {
    transition: none;
    animation: playhead linear both;
    animation-timeline: --tools;
    animation-range: contain 0% contain 100%;
  }
}

@keyframes playhead {
  from { transform: translateX(0%); }
  to   { transform: translateX(100%); }
}

/* ---------------- install ---------------- */

.install-track {
  list-style: none;
  margin-top: 28px;
  display: grid;
  grid-template-columns: 0.85fr 1.35fr 1.1fr;
  gap: 8px;
  counter-reset: step;
}

.install-track li {
  counter-increment: step;
  position: relative;
  padding: 22px 26px 24px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-alt);
}

.install-track h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.install-track h3::before {
  content: counter(step);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
}

.install-track p {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-mid);
}

.install-foot {
  margin-top: 18px;
  max-width: 80ch;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-dim);
}

.plugin-page .content-page a:not([class]) {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  transition: text-decoration-color 0.2s ease;
}

.plugin-page .content-page a:not([class]):hover { text-decoration-color: var(--ink); }

/* ---------------- facts ---------------- */

.facts-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(28px, 4vw, 72px);
}

.facts-col { padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.facts-col h3 { font-size: 15px; font-weight: 600; color: var(--text-dim); }
.facts-col dl { margin-top: 18px; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px 20px; }
.facts-col dt { font-size: 15px; font-weight: 600; }
.facts-col dd { font-size: 15px; line-height: 1.55; color: var(--text-mid); }

/* ---------------- close ---------------- */

.p-close { padding-bottom: clamp(24px, 4vh, 48px); }

.p-mail {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px 13px 18px;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: rgba(27, 27, 27, 0.55);
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
}

.p-mail:hover { background: #232323; transform: translateY(-2px); }

/* ---------------- plugins index ---------------- */

.plugin-list { display: grid; gap: 16px; }

.plugin-card {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 48px);
  align-items: center;
  padding: clamp(12px, 1.4vw, 18px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: #fff;
  text-decoration: none;
  transition: transform 0.35s var(--ease), border-color 0.3s ease, background 0.3s ease, box-shadow 0.35s var(--ease);
}

.plugin-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.18);
  background: #181818;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
}

.plugin-media {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: calc(var(--radius) - 8px);
  overflow: hidden;
  background: #0e0e0e;
}

.plugin-media img,
.plugin-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plugin-media video { opacity: 0; transition: opacity 0.4s var(--ease); }
.plugin-card.is-previewing .plugin-media video { opacity: 1; }

.plugin-info { padding-right: clamp(0px, 2vw, 28px); }

.plugin-info h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(30px, 3vw, 46px);
  font-weight: 500;
  letter-spacing: -0.04em;
}

.plugin-info p {
  margin-top: 12px;
  font-size: clamp(15px, 1.15vw, 18px);
  line-height: 1.55;
  color: var(--text-mid);
  max-width: 40ch;
}

.plugin-meta { margin-top: 10px; font-size: 14px; color: var(--text-dim); }

.plugin-open {
  margin-top: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}

.plugin-open img { width: 18px; height: 18px; transition: transform 0.3s var(--ease); }
.plugin-card:hover .plugin-open img { transform: translateX(4px); }

/* ---------------- small screens ---------------- */

@media (max-width: 860px) {
  .p-hero { --film-w: 100%; }
  .p-intro { flex-direction: column; align-items: stretch; }
  .p-download { justify-content: center; }
  .install-track { grid-template-columns: 1fr; }
  .facts-grid { grid-template-columns: 1fr; }
  .facts-col dl { grid-template-columns: 1fr; gap: 4px; }
  .facts-col dd { margin-bottom: 12px; }
  .plugin-card { grid-template-columns: 1fr; }
  .plugin-info { padding: 4px 6px 10px; }
  .p-hint-desktop { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ph { transition: none; }
  .mon-text.is-swapping { animation: none; }
  .mon-demo video { transition: none; }
}
