/* clip.css: the floating video box opened by the hero button "ดูคลิปแนะนำ" on krobjobsystem.com (28 พ.ย. 2569).
   Owner decision 28 พ.ย. 2569: ส่วนที่ 2 (คลิปแนะนำ) is no longer a section of the page. The hero button opens the clip in a native
   <dialog id="kj-clip" class="clip"> over the page instead. The video itself arrives later, so every variant also has a placeholder
   state (16:9 navy frame, "คลิปแนะนำกำลังมา", a link to #demo). clip.js swaps the placeholder for the player only while the box is open.
   One file serves the three variants: the dialog carries clip-a, clip-b or clip-c and that class only changes the layout and the scrim.
     A: centred lightbox, player up to 960 px wide, 16 px corners, navy scrim at 82%, close button above the frame at the top right
        (inside the frame on phones), white caption under the player. No gold in the box.
     B: theatre, the player spans the full viewport width (it narrows only when the height will not fit 16:9), black scrim at 95%,
        caption bar under the player: title left, gold button "นัด Demo 30 นาที" right. One gold point.
     C: card, player 2/3 left and a white panel 1/3 right (title, three lines of what the clip shows, gold button); on phones the panel
        goes under the player. One gold point.
   The dialog itself is the scrim: it fills the viewport, paints the scrim colour and is a size container, so the layout reads the
   viewport through container queries and container units. The same markup as a plain <div class="clip"> inside a fixed-size box
   lays out the same way on the choice page index.html (390 px phone box, desktop box).
   Close: Lucide x 20 px, white, inside a 40 px navy circle (DESIGN.md icon rule), on a 44 px hit area. The focus ring hugs the circle.
   Colour tokens come from the page's :root block (index.html and demo.html today, the site's global tokens later):
   --navy --gold --white --h-ink --h-muted --h-line --h-tint --font-head --font-body (plus --navy-muted when the page has it).
   Every px and ms below is declared once as a custom property, so the rules only ever use var(). */

/* ds-allow-hardcode:start */
.clip {
  --cl-max-a: 960px;        /* A: widest player */
  --cl-max-c: 1120px;       /* C: widest card (player 2/3 + panel 1/3) */
  --cl-max-c-m: 640px;      /* C stacked: widest card */
  --cl-min: 260px;          /* the player never shrinks below this when the viewport is very short */
  --cl-radius: 16px;
  --cl-radius-sm: 6px;
  --cl-btn: 48px;           /* DESIGN.md: every button at least 48 px tall */
  --cl-btn-pad: 24px;
  --cl-btn-radius: 10px;
  --cl-btn-border: 2px;
  --cl-tap: 44px;           /* close button hit area */
  --cl-dot: 40px;           /* the navy circle of the close button and of the placeholder icon */
  --cl-icon: 20px;
  --cl-tick: 28px;          /* C list: tick circle, same as the price list */
  --cl-ring: 3px;
  --cl-ring-gap: 2px;
  --cl-hair: 1px;
  --cl-ul: 1px;
  --cl-ul-hover: 2px;
  --cl-ul-gap: 3px;
  --cl-link-pad: 10px;      /* inline link: vertical padding grows the hit area to 44 px without growing the line box */
  --cl-s1: 4px;
  --cl-s2: 8px;
  --cl-s3: 12px;
  --cl-s4: 16px;
  --cl-s5: 20px;
  --cl-s6: 24px;
  --cl-s7: 32px;
  --cl-gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --cl-gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --cl-safe-t: env(safe-area-inset-top, 0px);
  --cl-safe-b: env(safe-area-inset-bottom, 0px);
  /* height kept free around the player when it is sized from the viewport height (padding, close row, caption) */
  --cl-a-reserve: 96px;
  --cl-a-reserve-lg: 200px;
  --cl-b-reserve: 196px;
  --cl-b-reserve-lg: 152px;
  --cl-c-reserve: 80px;
  /* type */
  --cl-fs: 16px;
  --cl-fs-cap: 17px;        /* A caption */
  --cl-fs-h: 18px;          /* B title */
  --cl-fs-hc: 22px;         /* C title */
  --cl-fs-ph-h: 20px;       /* placeholder heading */
  --cl-fs-ph-h-lg: 28px;
  --cl-lh: 1.6;
  --cl-lh-h: 1.3;
  --cl-lh-btn: 1.4;
  /* motion: one fade of the scrim and one short rise of the box, both off under prefers-reduced-motion */
  --cl-rise: 12px;
  --cl-dur: 240ms;
  --cl-ease: cubic-bezier(.16, 1, .3, 1);
  /* colours */
  --cl-scrim: color-mix(in srgb, var(--navy, #0a1628) 82%, transparent);
  --cl-frame: var(--navy);
  --cl-ink: var(--white);
  --cl-ink-muted: var(--navy-muted, #a9b5cc);
  --cl-line: color-mix(in srgb, var(--white) 16%, transparent);
  --cl-dot-bg: var(--navy);
  --cl-dot-hover: color-mix(in srgb, var(--white) 16%, var(--navy));
  --cl-ring-c: var(--white);
  --cl-panel: var(--white);
  --cl-panel-ink: var(--h-ink);
  --cl-panel-head: var(--navy);
  --cl-black: #000000;
}
/* B: black theatre scrim */
.clip-b { --cl-scrim: color-mix(in srgb, var(--cl-black) 95%, transparent); }
/* ds-allow-hardcode:end */

/* ---------- the dialog is the scrim ---------- */
.clip {
  container: clip / size;
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--cl-scrim);
  color: var(--cl-ink);
  font-family: var(--font-body);
  font-size: var(--cl-fs);
  line-height: var(--cl-lh);
  -webkit-text-size-adjust: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}
dialog.clip:not([open]) { display: none; }
.clip::backdrop { background: transparent; }
.clip *, .clip *::before, .clip *::after { box-sizing: border-box; }
.clip h2, .clip p, .clip ul { margin: 0; }
.clip ::selection { background: var(--cl-ink); color: var(--navy); }
.clip .nw { white-space: nowrap; }

.clip[open] { animation: cl-fade var(--cl-dur) var(--cl-ease); }
.clip[open] .clip-box { animation: cl-rise var(--cl-dur) var(--cl-ease); }
@keyframes cl-fade { from { opacity: 0; } }
@keyframes cl-rise { from { transform: translateY(var(--cl-rise)); } }
@media (prefers-reduced-motion: reduce) {
  .clip[open], .clip[open] .clip-box { animation: none; }
}

/* the page behind does not scroll while the box is open (clip.js sets the class on <html>) */
html.kj-clip-open { overflow: hidden; }

/* .clip-in fills the dialog and centres the box; a click on it (outside the box) closes the dialog, like the backdrop */
.clip-in {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: calc(var(--cl-s4) + var(--cl-safe-t)) var(--cl-gutter-r) calc(var(--cl-s4) + var(--cl-safe-b)) var(--cl-gutter-l);
}
.clip-box { position: relative; width: 100%; min-width: 0; display: grid; }

/* ---------- the player frame, shared ---------- */
.clip-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--cl-frame);
  border: var(--cl-hair) solid var(--cl-line);
  border-radius: var(--cl-radius);
}
.clip-media {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--cl-black);
}

/* placeholder: the state the box shows until the owner sends the clip */
.clip-ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--cl-s2);
  padding: var(--cl-s4);
  text-align: center;
}
.clip-ph-dot {
  display: grid;
  place-items: center;
  width: var(--cl-dot);
  height: var(--cl-dot);
  border-radius: 50%;
  border: var(--cl-hair) solid var(--cl-line);
  color: var(--cl-ink);
}
.clip-ph-dot svg { width: var(--cl-icon); height: var(--cl-icon); }
.clip-ph-h {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--cl-fs-ph-h);
  line-height: var(--cl-lh-h);
  color: var(--cl-ink);
  text-wrap: balance;
}
.clip-ph-p { max-width: 30em; color: var(--cl-ink-muted); text-wrap: pretty; }
.clip-ph-p a {
  padding-block: var(--cl-link-pad);
  color: var(--cl-ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: var(--cl-ul);
  text-underline-offset: var(--cl-ul-gap);
  white-space: nowrap;
}
.clip-ph-p a:hover { text-decoration-thickness: var(--cl-ul-hover); }
@container clip (min-width: 720px) {
  .clip-ph { gap: var(--cl-s3); }
  .clip-ph-h { font-size: var(--cl-fs-ph-h-lg); }
}

/* ---------- close button: 44 px hit area, 40 px navy circle, white x ---------- */
.clip-x {
  position: absolute;
  z-index: 1;
  top: var(--cl-s1);
  right: var(--cl-s1);
  display: grid;
  place-items: center;
  width: var(--cl-tap);
  height: var(--cl-tap);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cl-ink);
  cursor: pointer;
}
.clip-x-dot {
  display: grid;
  place-items: center;
  width: var(--cl-dot);
  height: var(--cl-dot);
  border-radius: 50%;
  background: var(--cl-dot-bg);
  border: var(--cl-hair) solid var(--cl-line);
}
.clip-x svg { width: var(--cl-icon); height: var(--cl-icon); }
.clip-x:hover .clip-x-dot { background: var(--cl-dot-hover); }
.clip-x:active .clip-x-dot { transform: translateY(var(--cl-hair)); }
/* the hit area is 2 px wider than the circle on each side, so an outline on the button sits 2 px off the circle */
.clip .clip-x:focus-visible { outline: var(--cl-ring) solid var(--cl-ring-c); outline-offset: 0; }

/* ---------- title, list, gold button ---------- */
.clip-side { display: grid; gap: var(--cl-s3); min-width: 0; }
.clip-h { color: var(--cl-ink); text-wrap: balance; }
.clip-list { display: grid; gap: var(--cl-s3); padding: 0; list-style: none; }
.clip-list li {
  display: grid;
  grid-template-columns: var(--cl-tick) minmax(0, 1fr);
  gap: var(--cl-s3);
  align-items: start;
  color: var(--cl-panel-ink);
  text-wrap: pretty;
}
.clip-tick {
  display: grid;
  place-items: center;
  width: var(--cl-tick);
  height: var(--cl-tick);
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
}
.clip-tick svg { width: var(--cl-icon); height: var(--cl-icon); }
.clip-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--cl-btn);
  padding: 0 var(--cl-btn-pad);
  border-radius: var(--cl-btn-radius);
  background: var(--gold);
  color: var(--navy);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--cl-fs);
  line-height: var(--cl-lh-btn);
  text-decoration: none;
  white-space: nowrap;
}
/* DESIGN.md gold rule: hover keeps the one gold and shows a navy inner border */
.clip-cta:hover { background: var(--gold); color: var(--navy); box-shadow: inset 0 0 0 var(--cl-btn-border) var(--navy); }
.clip-cta:active { transform: translateY(var(--cl-hair)); }

.clip a:focus-visible, .clip button:focus-visible {
  outline: var(--cl-ring) solid var(--cl-ring-c);
  outline-offset: var(--cl-ring-gap);
  border-radius: var(--cl-radius-sm);
}
.clip .clip-cta:focus-visible { border-radius: var(--cl-btn-radius); }

/* ============ A: centred lightbox ============ */
.clip-a .clip-box { width: min(100%, var(--cl-max-a), max(var(--cl-min), calc((100cqh - var(--cl-a-reserve)) * 16 / 9))); }
.clip-a .clip-side { margin-top: var(--cl-s3); }
.clip-a .clip-h { font-weight: 500; font-size: var(--cl-fs-cap); line-height: var(--cl-lh); }
.clip-a .clip-list, .clip-a .clip-cta { display: none; }
/* from 720 px the close button leaves the frame: it sits above it, the circle flush with the frame's right edge */
@container clip (min-width: 720px) {
  .clip-a .clip-in { padding-block: calc(var(--cl-tap) + var(--cl-s2) + var(--cl-s5) + var(--cl-safe-t)) calc(var(--cl-tap) + var(--cl-s2) + var(--cl-s5) + var(--cl-safe-b)); }
  .clip-a .clip-box { width: min(100%, var(--cl-max-a), max(var(--cl-min), calc((100cqh - var(--cl-a-reserve-lg)) * 16 / 9))); }
  .clip-a .clip-x { top: calc(-1 * (var(--cl-tap) + var(--cl-s2))); right: calc((var(--cl-dot) - var(--cl-tap)) / 2); }
}

/* ============ B: theatre ============ */
.clip-b .clip-in { padding: var(--cl-safe-t) 0 var(--cl-safe-b); }
.clip-b .clip-box { width: min(100%, max(var(--cl-min), calc((100cqh - var(--cl-b-reserve)) * 16 / 9))); }
.clip-b .clip-x { position: static; justify-self: end; margin: var(--cl-s2) var(--cl-gutter-r) var(--cl-s2) 0; }
.clip-b .clip-frame { border: 0; border-radius: 0; }
.clip-b .clip-side { padding: var(--cl-s4) var(--cl-gutter-r) var(--cl-s4) var(--cl-gutter-l); }
.clip-b .clip-h { font-family: var(--font-head); font-weight: 700; font-size: var(--cl-fs-h); line-height: var(--cl-lh-h); }
.clip-b .clip-list { display: none; }
@container clip (min-width: 600px) {
  .clip-b .clip-box { width: min(100%, max(var(--cl-min), calc((100cqh - var(--cl-b-reserve-lg)) * 16 / 9))); }
  .clip-b .clip-side { display: flex; align-items: center; justify-content: space-between; gap: var(--cl-s3) var(--cl-s6); }
}

/* ============ C: card with a side panel ============ */
.clip-c .clip-in { padding-top: calc(var(--cl-tap) + var(--cl-s2) + var(--cl-s4) + var(--cl-safe-t)); }
.clip-c .clip-box {
  width: min(100%, var(--cl-max-c-m));
  background: var(--cl-frame);
  border-radius: var(--cl-radius);
}
.clip-c .clip-frame { border: 0; border-radius: var(--cl-radius) var(--cl-radius) 0 0; align-self: center; }
/* stacked: the close button sits above the card, the circle flush with its right edge */
.clip-c .clip-x { top: calc(-1 * (var(--cl-tap) + var(--cl-s2))); right: calc((var(--cl-dot) - var(--cl-tap)) / 2); }
.clip-c .clip-side {
  --cl-ring-c: var(--navy);
  gap: var(--cl-s4);
  padding: var(--cl-s5);
  background: var(--cl-panel);
  color: var(--cl-panel-ink);
  border-radius: 0 0 var(--cl-radius) var(--cl-radius);
}
.clip-c .clip-side ::selection { background: var(--navy); color: var(--white); }
.clip-c .clip-h { font-family: var(--font-head); font-weight: 700; font-size: var(--cl-fs-hc); line-height: var(--cl-lh-h); color: var(--cl-panel-head); }
.clip-c .clip-cta { width: 100%; }
@container clip (min-width: 900px) {
  .clip-c .clip-in { padding-block: calc(var(--cl-s7) + var(--cl-safe-t)) calc(var(--cl-s7) + var(--cl-safe-b)); }
  .clip-c .clip-box {
    width: min(100%, var(--cl-max-c), max(var(--cl-min), calc((100cqh - var(--cl-c-reserve)) * 8 / 3)));
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  }
  .clip-c .clip-frame { border-radius: var(--cl-radius) 0 0 var(--cl-radius); }
  .clip-c .clip-side { align-content: center; padding: var(--cl-s7); border-radius: 0 var(--cl-radius) var(--cl-radius) 0; }
  .clip-c .clip-h { padding-right: var(--cl-tap); }
  /* on the white panel: the circle stays navy, its ring turns navy */
  .clip-c .clip-x { --cl-ring-c: var(--navy); top: var(--cl-s3); right: var(--cl-s3); }
}

