/* =============================================================================
   AI 안전관리 쪽 (ai.css) · 3차 지시(2026-10-02): 라이브 /ai 구조 그대로, 그림 배치만 다듬는다
   세 안 폴더(src/a · b · c)에 같은 파일이 들어간다. 그래서 v-<안> 부품(카드 · 시트 · 히어로)에 기대지 않고
   이 쪽에 필요한 규칙을 전부 여기 담는다. 공통 틀(cm-toss.css · min.css)의 토큰과 부품만 쓴다.
     1. 토큰            그림 칸 바탕 · 화면 그림자 (서체는 공통 틀의 Pretendard 토큰을 그대로 쓴다)
     2. .ai-hero        왼쪽 제목 · 버튼, 오른쪽 화면 둘
     3. .ai-work        '클린미션 AI가 하는 일': 묶음 머리글 + 카드 격자
     4. .ai-card        제목 칸(두 줄 높이) + 그림 칸(같은 비율, 그림은 통째로) + 더하기 단추
     5. .ai-contact     상담 블록
     6. .ai-sheet       상세: 제목 문장 + 시연 무대 + 상담 버튼
     7. .ai-play        시연 재생 층(ai.js 가 그림 위에 얹는다. 없어도 그림만으로 완결)
   ============================================================================= */

/* ---- 1. 토큰 -------------------------------------------------------------------- */
/* 서체는 공통 틀이 Pretendard 한 벌로 정한다(--min-font-title · --min-font-body). 여기서는 서체 이름을 적지 않는다 */
.ai-hero, .ai-work, .ai-qna, .ai-contact, .ai-sheet {
  --ai-gap: 20px;
  /* 그림 칸 · 시연 무대의 옅은 바탕: 위쪽 배경 빛과 같은 파랑 · 보라를 아주 옅게 */
  --ai-well: linear-gradient(180deg, rgba(49, 130, 246, 0.055), rgba(105, 41, 255, 0.06));
  --ai-screen-shadow: 0 1px 2px rgba(23, 92, 211, 0.06), 0 10px 28px rgba(23, 92, 211, 0.1);
}

/* ---- 2. 히어로 ------------------------------------------------------------------ */
/* 빛이 반투명 헤더 뒤까지 이어지도록 헤더 높이만큼 끌어올린다(공통 .min-hero 와 같은 값) */
.ai-hero {
  margin-top: calc(-1 * (var(--min-hd-h) + var(--min-safe-t)));
  padding-top: calc(var(--min-hd-h) + var(--min-safe-t) + clamp(36px, 6vw, 84px));
  padding-bottom: clamp(36px, 5vw, 72px);
  text-align: center;
}
.ai-hero__grid { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: clamp(36px, 5vw, 56px); }
.ai-hero__copy { min-width: 0; }
.ai-hero__scene { position: relative; width: min(100%, 720px); margin: 0 auto; padding: 0 6% 5% 0; }
.ai-hero__web {
  display: block; width: 100%; height: auto; background: #fff;
  border: 1px solid var(--cm-line-2); border-radius: 14px; box-shadow: var(--cm-shadow-3);
}
.ai-hero__phone {
  position: absolute; right: 0; bottom: 0; display: block; width: 23%; height: auto; background: #fff;
  border: 4px solid #fff; border-radius: 18px; box-shadow: 0 16px 40px rgba(23, 92, 211, 0.18);
}
@media (min-width: 900px) {
  .ai-hero { text-align: left; }
  .ai-hero__grid { grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr); }
  .ai-hero .min-actions { justify-content: flex-start; }
  .ai-hero .min-actions .cm-btn { min-width: 220px; }
  .ai-hero__scene { width: 100%; margin: 0; }
}
@media (max-width: 599px) {
  .ai-hero__web { border-radius: 10px; }
  .ai-hero__phone { border-width: 3px; border-radius: 12px; }
}

/* ---- 3. 클린미션 AI가 하는 일 ------------------------------------------------------ */
.ai-work__title { text-align: left; }
.ai-groups { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(48px, 6vw, 80px); margin-top: var(--min-head-gap); }
.ai-group { min-width: 0; }
/* 묶음 머리글: 이름 + 오른쪽 끝까지 가는 선. 묶음 사이는 넓은 간격으로 나눈다 */
.ai-group__head { display: flex; align-items: center; gap: 16px; margin: 0 0 clamp(14px, 1.8vw, 22px); }
.ai-group__head::after { content: ""; flex: 1; height: 1px; background: var(--cm-line-2); }
.ai-group__name { margin: 0; font-size: clamp(19px, 1.8vw, 24px); line-height: 1.3; }

.ai-cards {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ai-gap);
  margin: 0; padding: 0; list-style: none;
}
.ai-cards > li { display: flex; min-width: 0; margin: 0; padding: 0; }
@media (max-width: 1023px) { .ai-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 679px) {
  .ai-cards { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}
/* 현장 AI(5장) + 장비 연동(1장): 장비 연동은 한 장짜리 묶음이라 현장 AI 격자의 마지막 빈 칸에 놓는다.
   머리글은 그 칸 바로 위에 그대로 둔다. 그래서 열두 장이 끊김 없는 격자가 된다(좁은 화면은 위아래로 쌓는다) */
.ai-tail { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(48px, 6vw, 80px) var(--ai-gap); }
@media (min-width: 680px) {
  .ai-tail {
    grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 0;
    /* 마지막 줄 위에 머리글이 들어갈 자리: 머리글 높이 + 머리글 아래 여백 + 위 숨 */
    --ai-room: calc(clamp(19px, 1.8vw, 24px) * 1.3 + clamp(14px, 1.8vw, 22px) + 28px);
  }
  .ai-tail > .ai-group--field { grid-column: 1 / -1; grid-row: 1; }
  .ai-tail > .ai-group--device { grid-column: -2 / -1; grid-row: 1; align-self: end; }
  .ai-group--device .ai-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 680px) and (max-width: 1023px) {
  .ai-group--field .ai-cards > li:nth-child(n + 5) { margin-top: var(--ai-room); }
}
@media (min-width: 1024px) {
  .ai-tail { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ai-group--field .ai-cards > li:nth-child(n + 4) { margin-top: var(--ai-room); }
}

/* ---- 4. 카드 = 제목 칸 + 그림 칸 --------------------------------------------------- */
/* li 는 등장 모션이, .ai-card 는 뜨는 모션이 쓴다(둘을 합치지 않는다) */
.ai-card {
  position: relative; display: flex; flex-direction: column; width: 100%; overflow: hidden;
  background: #fff; border: 1px solid var(--cm-line); border-radius: var(--cm-r-card); box-shadow: var(--cm-shadow-2);
  text-align: left;
  transition: transform 200ms var(--cm-ease-out), box-shadow 240ms var(--cm-ease-out);
}
/* 제목 칸: 두 줄 높이로 통일. 더하기 단추는 언제나 오른쪽 가운데 */
.ai-card__head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 20px 16px 16px 22px;
}
.ai-card__title {
  display: flex; align-items: center; min-height: 2.8em; margin: 0; color: var(--cm-ink);
  font-family: var(--min-font-title); font-weight: 700; font-size: clamp(17px, 1.45vw, 20px); line-height: 1.4; letter-spacing: var(--min-ls-h3, -0.02em);
  text-wrap: balance;
}
/* 누르는 자리는 제목 안의 버튼 하나. ::after 가 카드 전체를 덮는다 */
.ai-card__hit {
  -webkit-appearance: none; appearance: none; margin: 0; padding: 0; border: 0; background: none; cursor: pointer;
  color: inherit; font: inherit; letter-spacing: inherit; text-align: inherit; text-wrap: inherit;
  -webkit-tap-highlight-color: transparent;
}
.ai-card__hit::after { content: ""; position: absolute; inset: 0; border-radius: var(--cm-r-card); }
.min-page .ai-card__hit:focus-visible { outline: none; }
.ai-card__hit:focus-visible::after { outline: 2px solid var(--cm-brand); outline-offset: -3px; }
/* 더하기 단추(상세가 열린다는 표시). 글자가 아니라 표시라서 읽기 도구에는 숨긴다 */
.ai-card__more {
  position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background-color: var(--cm-brand-tint); color: var(--cm-brand);
  transition: background-color var(--cm-t-fast) ease, color var(--cm-t-fast) ease;
}
.ai-card__more::before, .ai-card__more::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 2px; margin: -1px 0 0 -7px;
  border-radius: 2px; background-color: currentColor;
}
.ai-card__more::after { transform: rotate(90deg); }
/* 그림 칸: 카드 안쪽에 한 칸 들여 놓은 옅은 바탕. 열두 장이 같은 비율이고, 그림은 그 안에 통째로 들어간다 */
.ai-card__thumb {
  display: grid; place-items: center; margin: 0 12px 12px; padding: 18px; overflow: hidden;
  aspect-ratio: 6 / 7; max-height: 460px; border-radius: 16px; background: var(--ai-well);
  box-shadow: inset 0 0 0 1px rgba(105, 41, 255, 0.05);
}
.ai-card__thumb img {
  display: block; width: auto; height: 100%; max-width: 100%; min-height: 0; object-fit: contain;
  border-radius: 10px; box-shadow: var(--ai-screen-shadow); outline: 1px solid rgba(25, 31, 40, 0.05); outline-offset: -1px;
  transition: transform 240ms var(--cm-ease-out);
}
.ai-card:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) {
  .ai-card:hover { transform: translateY(-3px); box-shadow: var(--cm-shadow-3); }
  .ai-card:hover .ai-card__more { background-color: var(--cm-brand); color: #fff; }
  .ai-card:hover .ai-card__thumb img { transform: translateY(-3px); }
  .ai-card:active { transform: scale(0.985); }
}
@media (max-width: 359px) { .ai-card__hit .min-nb { white-space: normal; } }   /* 아주 좁은 화면에서는 제목 묶음도 접힌다 */
@media (max-width: 679px) {
  .ai-card__head { padding: 18px 14px 14px 20px; }
  .ai-card__title { font-size: 18px; }
  .ai-card__thumb { padding: 16px; }
}

/* ---- 5. 상담 블록 ----------------------------------------------------------------- */
.ai-contact { text-align: center; }
/* 타원을 섹션 안쪽에 두어 위아래 가장자리가 선으로 보이지 않게 한다(진하기는 스킬 값 그대로) */
.ai-contact > .cm-bg--band {
  height: 100%;
  background: radial-gradient(ellipse 60% 55% at 86% 42%, var(--cm-glow-1), var(--cm-glow-2) 44%, transparent 70%);
}
.ai-contact > .cm-bg--band .cm-bg__glow { --y: 2%; }

/* ---- 6. 상세 -------------------------------------------------------------------- */
html[data-ai-lock] { overflow: hidden; }
html[data-ai-lock] body { padding-right: var(--ai-sbw, 0px); }

.ai-sheet {
  --ai-sheet-w: 1248px;
  --ai-shot-h: clamp(240px, calc(100vh - 300px), 592px);   /* 시연 무대 안 그림 높이. 화면이 낮으면 줄어든다 */
  position: fixed; inset: 0; z-index: var(--min-z-sheet, 80);
  display: none; align-items: center; justify-items: center;
  padding: 24px max(24px, var(--min-safe-r)) 24px max(24px, var(--min-safe-l));
}
@supports (height: 100dvh) { .ai-sheet { --ai-shot-h: clamp(240px, calc(100dvh - 300px), 592px); } }
.ai-sheet[data-show] { display: grid; }
.ai-sheet__scrim {
  position: absolute; inset: 0; background: rgba(15, 18, 24, 0.5); touch-action: none;
  opacity: 0; transition: opacity 160ms var(--cm-ease-out);
}
.ai-sheet[data-open] .ai-sheet__scrim { opacity: 1; transition-duration: 240ms; }
.ai-sheet__panel {
  position: relative; display: flex; flex-direction: column;
  width: min(100%, var(--ai-sheet-w)); max-height: 100%; overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border-radius: var(--cm-r-sheet); box-shadow: 0 24px 72px rgba(23, 92, 211, 0.2);
  opacity: 0; transform: translateY(16px) scale(0.985);
  transition: opacity 160ms var(--cm-ease-out), transform 160ms var(--cm-ease-out);   /* 나갈 때가 더 빠르다 */
}
.ai-sheet[data-open] .ai-sheet__panel {
  opacity: 1; transform: none;
  transition: opacity 240ms var(--cm-ease-out), transform 320ms var(--cm-ease-drawer);
}
.ai-sheet[data-swap] .ai-sheet__scrim, .ai-sheet[data-swap] .ai-sheet__panel { transition: none; }   /* 이전 · 다음으로 넘길 때는 바탕이 깜박이지 않게 */
.min-page .ai-sheet__panel:focus { outline: none; }

.ai-sheet__head { display: flex; align-items: flex-start; gap: 16px; padding: 28px 28px 0 32px; }
.ai-sheet__title {
  flex: 1; min-width: 0; margin: 0; padding-top: 3px; color: var(--cm-ink);
  font-family: var(--min-font-title); font-weight: 700; font-size: clamp(21px, 2.3vw, 30px); line-height: 1.3; letter-spacing: var(--min-ls-h2, -0.02em);
  text-wrap: balance;
}
button.ai-sheet__close {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 44px; height: 44px; margin: 0; padding: 0;
  border: 0; border-radius: 50%; background-color: var(--cm-fill); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform var(--cm-t-press) var(--cm-ease-out), background-color var(--cm-t-fast) ease;
}
button.ai-sheet__close::before, button.ai-sheet__close::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 2px; margin: -1px 0 0 -8px;
  border-radius: 2px; background-color: var(--cm-ink-2); transform: rotate(45deg);
}
button.ai-sheet__close::after { transform: rotate(-45deg); }
button.ai-sheet__close:active { transform: scale(0.94); background-color: var(--cm-line-2); }
@media (hover: hover) and (pointer: fine) { button.ai-sheet__close:hover { background-color: var(--cm-line-2); } }

/* 시연 무대: 카드의 그림 칸과 같은 옅은 바탕 위에 화면 한 장 */
.ai-sheet__stage {
  margin: 20px 28px 0; padding: 20px; border-radius: 20px; background: var(--ai-well);
  box-shadow: inset 0 0 0 1px rgba(105, 41, 255, 0.05);
}
.ai-shot {
  position: relative; overflow: hidden; margin: 0 auto;
  width: min(100%, calc(var(--ar, 1.9) * var(--ai-shot-h))); aspect-ratio: var(--ar, 1.9);
  background: #fff; border-radius: 12px; box-shadow: var(--ai-screen-shadow);
}
.ai-shot > picture { display: block; width: 100%; height: 100%; }
.ai-shot > picture > img { display: block; width: 100%; height: 100%; max-width: none; object-fit: contain; }

.ai-sheet__foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 28px 28px 32px; }
.ai-sheet__foot .cm-btn { min-width: 220px; }
.ai-sheet__nav { display: flex; align-items: center; gap: 8px; }
.ai-sheet__count { min-width: 56px; color: var(--cm-ink-3); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; }
button.ai-sheet__step {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 44px; height: 44px; margin: 0; padding: 0;
  border: 0; border-radius: 50%; background-color: var(--cm-fill); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform var(--cm-t-press) var(--cm-ease-out), background-color var(--cm-t-fast) ease;
}
button.ai-sheet__step::before {   /* 꺾쇠 표시(글자가 아니라 그린 선) */
  content: ""; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; margin: -5px 0 0 -3px;
  border-left: 2px solid var(--cm-ink-2); border-bottom: 2px solid var(--cm-ink-2); border-radius: 1px; transform: rotate(45deg);
}
button.ai-sheet__step--next::before { margin-left: -7px; transform: rotate(-135deg); }
button.ai-sheet__step:active { transform: scale(0.94); background-color: var(--cm-line-2); }
@media (hover: hover) and (pointer: fine) { button.ai-sheet__step:hover { background-color: var(--cm-line-2); } }

/* 모바일: 아래에서 올라오는 시트. 머리와 상담 버튼은 붙어 있고 가운데만 스크롤된다 */
@media (max-width: 767px) {
  .ai-sheet { padding: 0; align-items: end; }
  .ai-sheet__panel {
    display: block; width: 100%;
    max-height: calc(100vh - 12px - var(--min-safe-t));
    border-radius: var(--cm-r-sheet) var(--cm-r-sheet) 0 0; box-shadow: 0 -12px 48px rgba(23, 92, 211, 0.16);
    opacity: 1; transform: translateY(100%);
    transition: transform 220ms var(--cm-ease-out);
  }
  @supports (height: 100dvh) { .ai-sheet__panel { max-height: calc(100dvh - 12px - var(--min-safe-t)); } }
  .ai-sheet[data-open] .ai-sheet__panel { transform: none; transition: transform var(--cm-t-sheet) var(--cm-ease-drawer); }
  .ai-sheet__panel[data-drag] { transition: none; }
  .ai-sheet__head {
    position: sticky; top: 0; z-index: 2; align-items: center; padding: 26px 12px 12px 20px;
    background: #fff; border-radius: var(--cm-r-sheet) var(--cm-r-sheet) 0 0; touch-action: none;
  }
  .ai-sheet__head::before {   /* 손잡이 */
    content: ""; position: absolute; left: 50%; top: 9px; width: 40px; height: 4px; margin-left: -20px;
    border-radius: 4px; background-color: var(--cm-line-2);
  }
  .ai-sheet__title { padding-top: 0; font-size: 20px; }
  .ai-sheet__stage { margin: 0 16px 16px; padding: 14px; border-radius: 16px; }
  .ai-shot { width: 100%; aspect-ratio: var(--ar-m, var(--ar, 1)); }
  .ai-sheet__foot {
    position: sticky; bottom: 0; z-index: 2; gap: 10px; padding: 12px 16px calc(12px + var(--min-safe-b));
    background: #fff; box-shadow: 0 -1px 0 var(--cm-line);
  }
  .ai-sheet__nav { gap: 6px; }
  .ai-sheet__count { display: none; }
  .ai-sheet__foot .cm-btn { flex: 1; min-width: 0; }
}

/* ---- 7. 시연 재생 층: 그림과 같은 자리 · 같은 크기. 준비되면 떠오르고, 감속 모드에서는 만들지 않는다 ---- */
.ai-play {
  position: absolute; inset: 0; overflow: hidden; background: #fff; pointer-events: none;
  opacity: 0; transition: opacity 240ms var(--cm-ease-out);
}
.ai-play[data-on] { opacity: 1; }
.ai-play > iframe { position: absolute; left: 0; top: 0; max-width: none; border: 0; transform-origin: 0 0; background: #fff; }

/* ---- 감속 · 대비 설정 --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ai-play { display: none; }
  .ai-card, .ai-card:hover, .ai-card:active { transform: none; transition: box-shadow 200ms ease; }
  .ai-card__thumb img, .ai-card:hover .ai-card__thumb img { transform: none; transition: none; }
  .ai-sheet__panel, .ai-sheet[data-open] .ai-sheet__panel { transform: none; transition: opacity 160ms ease; }
  button.ai-sheet__close:active, button.ai-sheet__step:active { transform: none; }
}
@media (prefers-reduced-motion: reduce) and (max-width: 767px) {
  .ai-sheet__panel { opacity: 0; }
  .ai-sheet[data-open] .ai-sheet__panel { opacity: 1; }
}
@media (prefers-contrast: more) {
  .ai-card, .ai-sheet__panel { border: 1px solid var(--cm-grey-500); box-shadow: none; }
  .ai-sheet__scrim { background: rgba(15, 18, 24, 0.72); }
  .ai-group__head::after { background: var(--cm-grey-500); }
}
/* 모션그래픽 영상(2026-10-03). 영상이 있는 상세는 원래 그림 대신 영상을 보인다. 틀 비율 16:9 는 마크업 인라인 값 */
.ai-shot[data-ai-video] { border-radius: 16px; overflow: hidden; background: #fff; }
.ai-shot[data-ai-video] > picture { display: none; }
.ai-shot[data-ai-video] > video { display: block; width: 100%; height: 100%; }
@media print {
  .ai-sheet { display: none; }
}
