
    uit4                        d Z ddlZddlZddlZddlmZ ddlZddlmZ  ed      Z	e	dz  Z
e	dz  Ze	dz  Ze	j                  d	d	
       ej                  j                  dd       ddlZdZdZdZdZdZdefdZdZdedefdZdededdfdZedk(  r{ ej                         Z ed        ed        ede         ed        e       Z ee      Z eee        ej                         ez
  Z edej@                   dedd        yy)!u   
Pilot A-3 (Solution) — Meta Carousel Slide
Deep navy → Gold/Ivory blueprint aesthetic
Hybrid: Gemini background + Playwright HTML overlay
    N)Path)sync_playwrightz4/home/jay/workspace/output/meta-ads/a-group-v6/pilotz	bg_A3.jpgzoverlay_A3.htmlzpilot-A3-solution.pngTparentsexist_okz&/home/jay/workspace/tools/ai-image-genz0https://generativelanguage.googleapis.com/v1betazgemini-3-pro-image-previewzgemini-3.1-flash-image-previewz3https://www.googleapis.com/auth/generative-languageux  
Create a dark, premium architectural blueprint visualization for a luxury insurance strategy advertisement.

COMPOSITION: 1:1 square, 1080x1080px. Full bleed.

SCENE: An intricate, glowing technical diagram — a precision sales flow network — unfolding in deep darkness.
Blueprint-style lines and nodes form a connected strategy map. The diagram has geometric precision:
clean vector-like glowing lines connecting circular and rectangular nodes.
Three clearly labeled node clusters are visible: flowing connection paths between them.

VISUAL LANGUAGE:
- Blueprint / engineering schematic aesthetic
- Glowing cyan-gold lines on deep navy background
- Lines and nodes reminiscent of circuit boards + architectural floor plans
- The system diagram occupies the center-left area of the frame
- Subtle grid pattern in extreme background (like graph paper, very faint)
- Depth: foreground elements sharp and bright, background fades into darkness

LIGHTING / COLOR:
- Dominant: Deep navy blue (#1A2F5E) to near-black
- Glowing elements: Gold (#C9A84C) and warm ivory lines
- Occasional faint teal-blue accent on technical grid lines
- Top 40% of image: deepest navy, almost black — good for text overlay
- Bottom 30%: slightly lighter, warm glow rising from lower-left as if dawn breaking —
  subtle gold-ivory light suggesting transition from dark to light (this is slide 3 of 5 in a dark-to-light journey)
- Overall: intelligent warmth, NOT cold tech blue

STYLE:
- Like a McKinsey strategy presentation visual made into premium advertising
- Premium, dark luxury advertising — Rolex / Patek Philippe meets consulting firm
- NO stock photo aesthetic
- NO people, faces, or human figures
- NO text or labels — all text will be overlaid separately
- NO bright white areas
- Cinematic quality, ultra-detailed

MOOD: Precision. Intelligence. Systematic. Warm authority. The system itself is the protagonist.
returnc            	        
 t         j                         rt        dt                 t         S t        d       t        j                  t
              
dt        dt        j                  f
fd} t        j                         } | t              }|j                  dv r%t        d|j                   d        | t              }|j                          |j                         }|d	   d
   d   d   }t        d |D        d       }|t!        dt        |      d d        |d   j#                  dd      }|d   d   }d|v rdnd}t         j%                  |      }	|	j'                  t)        j*                  |             t        d|	j,                   d|	j/                         j0                  ddt        j                         |z
  dd       |	S )Nu(   [BG] 기존 배경 이미지 재사용: u1   [BG] Gemini API로 배경 이미지 생성 중...model_idr   c                     t          d|  d}d dd}ddt        igigdd	d
gid}t        j                  |||d      S )Nz/models/z:generateContentzBearer zapplication/json)AuthorizationzContent-TypepartstextresponseModalitiesIMAGETEXT)contentsgenerationConfigi,  )headersjsontimeout)GEMINI_API_BASE	BG_PROMPTrequestspost)r
   urlr   payloadtokens       D/home/jay/workspace/output/meta-ads/a-group-v6/pilot/gen_pilot_A3.py_callz"generate_background.<locals>._callQ   sk     !(3CD&ug..

 "VY$7#89:!57H I
 }}S'MM    )i  i  u   [BG] Pro 모델 실패 (HTTP u   ), fallback 시도...
candidatesr   contentr   c              3   *   K   | ]  }d |v s|  yw)
inlineDataN ).0ps     r   	<genexpr>z&generate_background.<locals>.<genexpr>f   s     ;1):Q;s   	u   이미지 없음. 응답: i  r$   mimeTypez
image/jpegdatajpegz.jpgz.pngu   [BG] 완료:  (,z bytes, .1fu   초))BG_PATHexistsprintgcloud_authget_service_account_tokenSCOPEstrr   ResponsetimeMODEL_PRIMARYstatus_codeMODEL_FALLBACKraise_for_statusr   nextRuntimeErrorgetwith_suffixwrite_bytesbase64	b64decodenamestatst_size)r   t0respr*   r   img_partmimeb64extfpathr   s             @r   generate_backgroundrM   I   s   ~~8	BC	
=>11%8E
N 
N 1 1 
N 
BD:%-d.>.>-??TUV^$99;Dq!),W5E;;TBH7D	$37HIJJ\"&&z<@D\"6*CnF&C$E	f&&s+,	M%**R

(<(<Q'?x		TVWZG[[_
`aLr    ux  <!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<style>
  @font-face {{
    font-family: 'Pretendard';
    src: local('Pretendard Variable'),
         url('/home/jay/.local/share/fonts/Pretendard/PretendardVariable.ttf') format('truetype');
    font-weight: 100 900;
  }}

  * {{ margin: 0; padding: 0; box-sizing: border-box; }}

  html, body {{
    width: 1080px;
    height: 1080px;
    overflow: hidden;
    background: #0d1e3a;
  }}

  .canvas {{
    width: 1080px;
    height: 1080px;
    position: relative;
    background-image: url('{bg_url}');
    background-size: cover;
    background-position: center center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 56px 72px 60px 72px;
  }}

  /* Dark overlay gradient — heavier at top for text readability */
  .canvas::before {{
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
      180deg,
      rgba(10, 18, 42, 0.72) 0%,
      rgba(10, 18, 42, 0.48) 40%,
      rgba(10, 18, 42, 0.30) 65%,
      rgba(15, 25, 55, 0.55) 100%
    );
    pointer-events: none;
  }}

  /* All direct children above the overlay */
  .canvas > * {{ position: relative; z-index: 1; }}

  /* ── TOP: Brand badge ── */
  .top-zone {{
    display: flex;
    align-items: flex-start;
  }}

  .brand-badge {{
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid rgba(201, 168, 76, 0.55);
    border-radius: 6px;
    padding: 10px 20px;
    background: rgba(13, 30, 58, 0.60);
    backdrop-filter: blur(8px);
  }}

  .badge-dot {{
    width: 7px;
    height: 7px;
    background: #C9A84C;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(201, 168, 76, 0.8);
  }}

  .badge-text {{
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 28px;
    color: #C9A84C;
    letter-spacing: 0.04em;
    line-height: 1;
  }}

  /* ── MIDDLE: Headline zone ── */
  .middle-zone {{
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: center;
    padding: 20px 0;
  }}

  .eyebrow {{
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: 22px;
    color: rgba(201, 168, 76, 0.75);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 26px;
  }}

  .headline {{
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-weight: 800;
    font-size: 84px;
    line-height: 1.20;
    letter-spacing: -0.025em;
    color: #F5F0E8;
    margin-bottom: 0;
    word-break: keep-all;
  }}

  .headline .hl-gold {{
    color: #C9A84C;
    font-weight: 900;
  }}

  .divider {{
    width: 72px;
    height: 2px;
    background: linear-gradient(90deg, #C9A84C 0%, rgba(201, 168, 76, 0.15) 100%);
    margin: 38px 0 0 0;
  }}

  /* ── BOTTOM: Subcopy zone ── */
  .bottom-zone {{
    display: flex;
    flex-direction: column;
    gap: 0;
  }}

  /* Antithesis pair */
  .antithesis-block {{
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 24px;
  }}

  .antithesis-row {{
    display: flex;
    align-items: baseline;
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 44px;
    font-weight: 300;
    line-height: 1.55;
    color: rgba(240, 235, 225, 0.62);
    letter-spacing: -0.01em;
    white-space: nowrap;
  }}

  .antithesis-row .dim {{
    font-weight: 300;
    color: rgba(240, 235, 225, 0.55);
  }}

  .antithesis-row .sep {{
    color: rgba(201, 168, 76, 0.45);
    font-weight: 300;
    margin: 0 12px;
    font-size: 38px;
  }}

  .antithesis-row .kw {{
    font-weight: 800;
    color: #C9A84C;
    font-size: 46px;
    letter-spacing: -0.02em;
  }}

  /* Final sentence */
  .final-sentence {{
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 44px;
    font-weight: 500;
    color: rgba(240, 235, 225, 0.82);
    line-height: 1.5;
    letter-spacing: -0.015em;
    word-break: keep-all;
  }}

  .final-sentence .accent {{
    color: #C9A84C;
    font-weight: 700;
  }}

  /* Bottom meta */
  .bottom-meta {{
    margin-top: 30px;
    display: flex;
    align-items: center;
    gap: 14px;
  }}

  .meta-rule {{
    width: 28px;
    height: 1px;
    background: rgba(201, 168, 76, 0.5);
  }}

  .meta-label {{
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 19px;
    font-weight: 400;
    color: rgba(201, 168, 76, 0.55);
    letter-spacing: 0.12em;
  }}

  /* Slide indicator (top-right) */
  .slide-num {{
    position: absolute;
    top: 56px;
    right: 72px;
    z-index: 2;
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 20px;
    font-weight: 400;
    color: rgba(201, 168, 76, 0.50);
    letter-spacing: 0.06em;
  }}
</style>
</head>
<body>
<div class="canvas">

  <!-- Slide number -->
  <div class="slide-num">3 / 5</div>

  <!-- TOP: Brand badge -->
  <div class="top-zone">
    <div class="brand-badge">
      <div class="badge-dot"></div>
      <span class="badge-text">서울대보험쌤</span>
    </div>
  </div>

  <!-- MIDDLE: Headline -->
  <div class="middle-zone">
    <div class="eyebrow">SOLUTION · A-3</div>
    <h1 class="headline">
      서울대 출신 팀장이<br>
      보험 영업을<br>
      <span class="hl-gold">다시 설계했다.</span>
    </h1>
    <div class="divider"></div>
  </div>

  <!-- BOTTOM: Subcopy -->
  <div class="bottom-zone">
    <div class="antithesis-block">
      <div class="antithesis-row">
        <span class="dim">감각이 아닌</span>
        <span class="sep">—</span>
        <span class="kw">데이터</span><span class="dim">로,</span>
      </div>
      <div class="antithesis-row">
        <span class="dim">경험이 아닌</span>
        <span class="sep">—</span>
        <span class="kw">시스템</span><span class="dim">으로.</span>
      </div>
    </div>
    <div class="final-sentence">
      <span class="accent">혼자 뛰지 않아도 되는 구조</span>를 만들었다.
    </div>
    <div class="bottom-meta">
      <div class="meta-rule"></div>
      <span class="meta-label">SEOUL NATIONAL UNIV. · INSURANCE SYSTEM DESIGN</span>
    </div>
  </div>

</div>
</body>
</html>
bg_pathc                     d| j                          }t        j                  |      }t        j	                  |d       t        dt                t        S )Nfile://)bg_urlzutf-8)encodingu   [HTML] 오버레이 작성: )resolveHTML_TEMPLATEformat	HTML_PATH
write_textr1   )rN   rQ   htmls      r   
write_htmlrY     sR    w()*Fv.D0	(
45r    	html_pathout_pathc           
      n   t        d       t               5 }|j                  j                         }	 |j	                  ddd      }|j                  d| j                          d       |j                  d       |j                  d	       |j                  j                  d
d
       |j                  t        |      dddddd       |j                          	 d d d        |j                         j                  dz  }t        d| d|dd       y # |j                          w xY w# 1 sw Y   OxY w)Nu$   [RENDER] Playwright 캡처 시작...i8  )widthheight)viewportrP   networkidle)
wait_untilz+async () => { await document.fonts.ready; }i  Tr   pngr   )xyr]   r^   )pathtypeclipi   u   [RENDER] 완료: r,   z.0fz KB))r1   r   chromiumlaunchnew_pagegotorS   evaluatewait_for_timeoutparentmkdir
screenshotr5   closerD   rE   )rZ   r[   r'   browserpagesize_kbs         r   captureru     s   	02		 a**##%	##tt-L#MDII	 1 1 345-IPMMGH!!$'OO!!$!>OO]1ttD   MMO  mmo%%,G	hZr'#d
;< MMO s#   D+BDD+D((D++D4__main__z<============================================================u9   Pilot A-3 (Solution) — 하이브리드 이미지 생성u   출력: u
   
[완료] z  (r.   u   초 총 소요))!__doc__rA   sysr7   pathlibr   r   playwright.sync_apir   BASE_DIRr/   rV   OUT_PATHro   re   insertr2   r   r8   r:   r4   r   rM   rT   rY   ru   __name__t_startr1   bgrX   elapsedrC   r%   r    r   <module>r      s^    
    / FG{"((	.. td + ; < D.2G%	R'T 'XWt  =t =t = =0 zdiikG	(O	
EF	HXJ
 	(O		Bb>DD(diikG#G	Kc'#o
FG r    