/* 팜소프트 스튜디오 공통 스타일 — 팸스터디 "레트로 콘솔" 디자인 토큰
   토큰 출처: son-study-market app/lib/ui_kit.dart (kLightAppColors / kDarkAppColors,
   famstudy-retro/design-tokens.json 정확값) + design_kit.dart 레트로 컴포넌트 스펙
   타이포: Pretendard(본문) · IBM Plex Mono(브랜드/숫자/라벨) · Gaegu(장식 손글씨) */

:root {
  /* ── 색 토큰 (레트로 콘솔 라이트) ── */
  --bg: #EFE9D6;
  --ink: #1B1B1F;
  --subtle: #55555D;
  --faint: #8A8A92;
  --card: #FBF7EA;
  --panel: #FFFFFF;            /* app inputBg — 윈도우 위 카드/버튼 이차 패널 */
  --outline: #141417;
  --accent: #DE5A2A;
  --accent-pressed: #C24E24;
  --accent2: #3D66C9;
  --highlight: #F2C94C;
  --marker: #FBE08A;           /* sketch marker highlight — 제목 키워드 밴드 */
  --success: #2E7D4F;
  --success-soft: #8FBFA3;
  --warning: #C7912B;
  --danger: #C0392B;
  --pink: #FB7185;             /* category.meal — 미리봄 포인트 */
  --titlebar: #17171A;
  --titlebar-text: #F2EDDD;
  --disabled: #D9D3C0;
  --shadow: rgba(20, 20, 23, 0.55);   /* kHardShadow alpha 0.55 */
  --dot: rgba(27, 27, 31, 0.10);      /* DotGridBackground ink 10% */
  --max: 760px;
  /* ── 글씨체 토큰 ── */
  --font-body: "Pretendard Variable", Pretendard, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-hand: "Gaegu", "Pretendard Variable", cursive;
  /* ── 모션 ── */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── 색 토큰 (레트로 콘솔 다크 — kDarkAppColors) ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1C20;
    --ink: #F2EDDD;
    --subtle: #A9A9B2;
    --faint: #77777F;
    --card: #26262B;
    --panel: #2E2E34;
    --outline: #EAE4D2;
    --accent: #D8663C;
    --accent-pressed: #B84E28;
    --accent2: #5B7FD0;
    --highlight: #D9B450;
    --marker: #34375C;         /* kMarkerHiDark */
    --success: #3C8A5D;
    --success-soft: #557F68;
    --warning: #CFA045;
    --danger: #D05548;
    --titlebar: #17171A;
    --titlebar-text: #F2EDDD;
    --disabled: #4A4A52;
    --shadow: rgba(0, 0, 0, 0.55);
    --dot: rgba(242, 237, 221, 0.06);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
html.ps-preboot { overflow: hidden; }
html.ps-preboot body { opacity: 0; }
html.ps-preboot.ps-shown body { opacity: 1; }
body.ps-lock { overflow: hidden; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--bg);
  /* 점자 배경 — DotGridBackground(20px 간격, r1.1) */
  background-image: radial-gradient(var(--dot) 1.1px, transparent 1.2px);
  background-size: 20px 20px;
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
::selection { background: var(--marker); color: #1B1B1F; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }

/* ── 앱 윈도우: 페이지 전체가 하나의 FAMSTUDY.EXE 창 ── */
.wrap {
  max-width: var(--max);
  margin: 28px auto 72px;
  padding: 0 26px 52px;
  background: var(--card);
  border: 2px solid var(--outline);
  box-shadow: 10px 10px 0 var(--shadow);
}

/* ── 타이틀바 (RetroAppTitleBar: 프로그램명 + 실시간 시계) ── */
.titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -26px 26px;
  padding: 11px 16px;
  background: var(--titlebar);
  color: var(--titlebar-text);
  border-bottom: 2px solid var(--outline);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 2px;
}
.tb-dot {
  flex: none;
  width: 11px; height: 11px;
  background: var(--accent);
  border: 1.5px solid var(--titlebar-text);
}
.tb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-clock { flex: none; font-variant-numeric: tabular-nums; }

.site-header { padding: 0; }
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 22px 0 6px;
}
.logo {
  font-weight: 900; font-size: 21px; letter-spacing: -0.04em;
  text-decoration: none; display: inline-flex; align-items: center; gap: 10px;
}
.logo::before {
  content: "";
  width: 13px; height: 13px;
  background: var(--accent);
  border: 2px solid var(--outline);
  box-shadow: 2px 2px 0 var(--shadow);
}
.nav {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12.5px; font-weight: 500; letter-spacing: 0.5px;
}
.nav a {
  text-decoration: none; padding: 3px 1px; color: var(--subtle);
  background: linear-gradient(var(--marker), var(--marker)) 0 100% / 0% 42% no-repeat;
  transition: background-size 0.25s var(--ease-out), color 0.2s ease;
}
.nav a:hover { background-size: 100% 42%; color: var(--ink); }

/* ── 히어로 ── */
.hero { padding: 20px 0 38px; position: relative; }
.hero h1 {
  font-size: clamp(30px, 6.4vw, 44px); font-weight: 900;
  letter-spacing: -0.045em; line-height: 1.16; margin-bottom: 14px;
}
.hero .lead { font-size: 16.5px; color: var(--subtle); max-width: 34em; line-height: 1.65; }

/* 마커 하이라이트 — 부팅 완료 후 왼쪽에서 오른쪽으로 쓱 (design_kit marker 밴드 38%) */
.marker {
  padding: 0 3px; margin: 0 -3px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  background: linear-gradient(var(--marker), var(--marker)) 0 100% / 0% 38% no-repeat;
  transition: background-size 0.7s var(--ease-out) 0.25s;
}
body.is-live .marker { background-size: 100% 38%; }

/* 스탬프 — 레트로 사각 도장(회전 -7deg), 부팅 완료 후 쿵 찍힌다 */
.stamp {
  position: absolute; top: 8px; right: -2px; z-index: 1;
  font-family: var(--font-hand); font-weight: 700; font-size: 21px; line-height: 1;
  letter-spacing: 2px; color: var(--accent);
  border: 2.5px solid var(--accent);
  background: var(--card);
  padding: 8px 14px 6px;
  transform: rotate(-7deg) scale(1.7);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.45s var(--ease-pop) 0.6s, opacity 0.25s ease 0.6s;
}
body.is-live .stamp { transform: rotate(-7deg) scale(1); opacity: 1; }

/* ── 배지 (OutlineTag: r0 + 2px 색 테두리) ── */
.badge {
  display: inline-block;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 700;
  letter-spacing: 1.5px;
  padding: 6px 10px 5px;
  background: var(--panel);
  border: 2px solid var(--accent); color: var(--accent);
  box-shadow: 2px 2px 0 var(--shadow);
  margin-bottom: 14px;
}
.badge.mint { border-color: var(--accent2); color: var(--accent2); }
.badge.pale { border-color: var(--outline); color: var(--ink); }

/* ── 카드 (r0 + 2px 아웃라인 + 하드 섀도 4,4) ── */
.card {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--outline);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 22px;
  transition: transform 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}
.card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
.card + .card { margin-top: 18px; }
.grid { display: grid; gap: 18px; }
.grid .card + .card { margin-top: 0; }
@media (min-width: 640px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.product-name { font-size: 21px; font-weight: 900; letter-spacing: -0.03em; margin-bottom: 8px; }
.hook { font-size: 15px; color: var(--subtle); line-height: 1.6; margin-bottom: 18px; }

/* ── 버튼 (BevelButton: 상단 인셋 하이라이트 + 하드 섀도, 눌림 2,2) ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 22px;
  background: var(--accent); color: #fff;
  text-decoration: none; font-size: 15px; font-weight: 800; letter-spacing: -0.01em;
  border: 2px solid var(--outline); border-radius: 0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 4px 4px 0 var(--shadow);
  cursor: pointer;
  transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), background-color 0.15s ease;
}
.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 5px 5px 0 var(--shadow);
}
.btn:active {
  transform: translate(2px, 2px);
  background: var(--accent-pressed);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.15);
}
.btn.secondary { background: var(--panel); color: var(--ink); }
.btn.secondary:active { background: var(--disabled); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 140px; }

/* ── 섹션 ── */
.section { margin-top: 46px; }
.section h2, h2.section {
  display: flex; align-items: center; gap: 11px;
  font-size: 21px; font-weight: 900; letter-spacing: -0.03em; margin-bottom: 16px;
}
.section h2::before, h2.section::before {
  content: "";
  flex: none; width: 10px; height: 10px;
  background: var(--highlight);
  border: 2px solid var(--outline);
  box-shadow: 2px 2px 0 var(--shadow);
}
.section h3 { font-size: 16.5px; font-weight: 800; margin: 16px 0 8px; letter-spacing: -0.02em; }
.section p, .section li { color: var(--subtle); font-size: 15px; line-height: 1.7; }
.section strong { color: var(--ink); }
.section ul { padding-left: 1.2em; margin: 8px 0; }
.section li { margin: 5px 0; }
.section a { color: var(--accent2); font-weight: 700; }

/* ── 단계 (steps: 사각 카운터) ── */
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li {
  counter-increment: step; position: relative;
  padding: 15px 16px 15px 60px; margin-bottom: 12px;
  background: var(--panel); border: 2px solid var(--outline);
  box-shadow: 4px 4px 0 var(--shadow);
}
.steps li::before {
  content: counter(step);
  position: absolute; left: 15px; top: 14px;
  width: 29px; height: 29px;
  background: var(--accent2); color: #fff;
  border: 2px solid var(--outline);
  box-shadow: 2px 2px 0 var(--shadow);
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}

/* ── 추천/비추천 ── */
.split { display: grid; gap: 16px; }
@media (min-width: 640px) { .split { grid-template-columns: 1fr 1fr; } }
.fit { border-left: 6px solid var(--success); }
.nofit { border-left: 6px solid var(--danger); }

/* ── FAQ (Q → A 마커) ── */
.faq details {
  background: var(--panel); border: 2px solid var(--outline);
  box-shadow: 3px 3px 0 var(--shadow);
  padding: 15px 18px; margin-bottom: 12px;
}
.faq summary {
  font-weight: 800; font-size: 15.5px; cursor: pointer; list-style: none;
  letter-spacing: -0.02em;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: "Q.";
  font-family: var(--font-mono); font-weight: 700; color: var(--accent2);
  margin-right: 10px;
}
.faq details[open] summary::before { content: "A."; color: var(--success); }
.faq details p { margin-top: 10px; color: var(--subtle); font-size: 15px; line-height: 1.7; }

/* ── CTA 밴드 (터미널 반전: 다크 바디 + 크림 텍스트) ── */
.cta-band {
  margin-top: 50px; padding: 32px 26px;
  background: var(--titlebar); color: var(--titlebar-text);
  border: 2px solid var(--outline);
  box-shadow: 8px 8px 0 var(--shadow);
  text-align: center;
}
.cta-band h2 { font-size: 22px; font-weight: 900; letter-spacing: -0.03em; margin-bottom: 8px; }
.cta-band p { color: rgba(242, 237, 221, 0.72); margin-bottom: 20px; font-size: 15px; }
.cta-band .btn { box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), 4px 4px 0 rgba(0,0,0,0.5); }

/* ── 푸터 (점선 구분선 — DottedDivider) ── */
.site-footer {
  margin-top: 54px; padding-top: 20px;
  border-top: 2px dashed var(--faint);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.5px;
  color: var(--subtle); text-align: center;
}
.site-footer a {
  color: var(--subtle); text-decoration: none;
  background: linear-gradient(var(--marker), var(--marker)) 0 100% / 0% 42% no-repeat;
  transition: background-size 0.25s var(--ease-out), color 0.2s ease;
}
.site-footer a:hover { background-size: 100% 42%; color: var(--ink); }

.meta {
  display: block;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: 1.5px; color: var(--faint); margin-bottom: 12px;
}

/* ── 인사이트 글 (아티클 윈도우) ── */
.article {
  background: var(--panel); border: 2px solid var(--outline);
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 30px 26px;
}
.article h1 {
  font-size: 25px; font-weight: 900; letter-spacing: -0.035em;
  margin-bottom: 12px; line-height: 1.3;
}
.article h2 { font-size: 17.5px; font-weight: 800; margin: 26px 0 10px; letter-spacing: -0.02em; }
.article h2::before { content: "▸ "; font-family: var(--font-mono); color: var(--accent); }
.article p { margin: 10px 0; font-size: 15.5px; line-height: 1.8; color: var(--subtle); }
.article strong { color: var(--ink); }
.article ul, .article ol { margin: 8px 0 12px 1.2em; }
.article li { font-size: 15.5px; line-height: 1.75; color: var(--subtle); margin: 5px 0; }
.article a { color: var(--accent2); font-weight: 700; }

/* 목록 카드 화살표 */
.list-card { display: block; text-decoration: none; }
.list-card::after {
  content: "→";
  position: absolute; right: 18px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono); font-weight: 700; font-size: 16px;
  color: var(--accent);
  transition: transform 0.18s var(--ease-out);
}
.list-card:hover::after { transform: translate(4px, -50%); }
.list-card .product-name { padding-right: 26px; }

/* ── 제품 앱 윈도우 카드: 타이틀바(제품색 도트+프로그램명) + 실제 스크린샷 ── */
.appwin { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.appwin--famstudy { --pc: var(--accent); }
.appwin--familyview { --pc: var(--accent2); }
.appwin--manseryeok { --pc: var(--warning); }
.appwin--miribom { --pc: var(--pink); }
.appwin-bar {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px;
  background: var(--titlebar); color: var(--titlebar-text);
  border-bottom: 2px solid var(--outline);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 1.5px;
}
.appwin-dot {
  flex: none; width: 10px; height: 10px;
  background: var(--pc, var(--accent));
  border: 1.5px solid var(--titlebar-text);
}
.appwin-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appwin-meta { flex: none; color: rgba(242, 237, 221, 0.55); }
/* 플래그십(팸스터디) 타이틀바에는 깜빡이는 커서 — 살아 있는 디테일 */
.appwin--famstudy .appwin-name::after {
  content: "▮"; margin-left: 4px; color: var(--pc);
  animation: ps-blink 0.9s steps(2, start) infinite;
}
.appwin-shot {
  margin: 0; overflow: hidden;
  border-bottom: 2px solid var(--outline);
  background: #17171A;
  aspect-ratio: 1024 / 500;
}
.appwin-shot img {
  display: block; width: 100%; height: 100%;
  object-fit: contain;
  transition: transform 0.5s var(--ease-out);
}

.appwin:hover .appwin-shot img { transform: scale(1.03); }
.appwin-body { padding: 20px; flex: 1; display: flex; flex-direction: column; }
.appwin-body {
  background: var(--titlebar); color: var(--titlebar-text);
  border-top: none;
}
.appwin-body .badge { border-color: var(--pc, var(--accent)); color: var(--pc, var(--accent)); background: transparent; }
.appwin-body .product-name { color: var(--titlebar-text); }
.appwin-body .hook { color: rgba(242, 237, 221, 0.72); }
.appwin-body .btn { box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), 4px 4px 0 rgba(0,0,0,0.5); }
.appwin-body .btn.secondary { background: transparent; color: var(--titlebar-text); border-color: rgba(242,237,221,0.4); }
.appwin-body .btn.secondary:hover { background: rgba(242,237,221,0.08); }
.appwin-body .btn-row { margin-top: auto; }

/* 앱 윈도우 카드 전체를 하나의 다크 윈도우로: 외곽 outline만 라이트 */
.appwin { border-color: var(--outline); box-shadow: 6px 6px 0 var(--shadow); }


/* ── 스크롤 리빌 ── */
.rv {
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.6s var(--ease-out) var(--d, 0s), transform 0.6s var(--ease-out) var(--d, 0s);
}
.rv.in { opacity: 1; transform: none; }

/* ── 첫 진입: 부팅 오버레이 (레트로 콘솔 ROM BIOS) ── */
#ps-boot {
  position: fixed; inset: 0; z-index: 2147483000;
  background: var(--titlebar); color: var(--titlebar-text);
  display: flex; flex-direction: column;
  overflow: hidden; cursor: pointer;
  will-change: transform;
}
#ps-boot.out { transform: translateY(-102%); transition: transform 0.6s cubic-bezier(0.76, 0, 0.24, 1); }
#ps-boot .boot-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(242, 237, 221, 0.07) 1.1px, transparent 1.2px);
  background-size: 20px 20px;
}
/* CRT 주사선 */
#ps-boot::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px);
}
#ps-boot .boot-bar {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 2px solid rgba(242, 237, 221, 0.28);
  font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 2px;
}
#ps-boot .boot-sq { flex: none; width: 11px; height: 11px; background: var(--accent); border: 1.5px solid var(--titlebar-text); }
#ps-boot .boot-bar span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#ps-boot .boot-clock { flex: none; font-variant-numeric: tabular-nums; }
#ps-boot .boot-body {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; padding: 24px;
}
#ps-boot .boot-log {
  width: min(560px, 88vw); min-height: 118px;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 2;
  letter-spacing: 0.5px; color: rgba(242, 237, 221, 0.92);
  text-shadow: 0 0 7px rgba(242, 237, 221, 0.22);
  white-space: pre-wrap;
}
#ps-boot .boot-line.boot-cursor::after {
  content: "▮"; margin-left: 2px; color: var(--accent);
  animation: ps-blink 0.9s steps(2, start) infinite;
}
@keyframes ps-blink { to { visibility: hidden; } }
/* 세그먼트 게이지 (SegmentGauge: 2px 테두리 + 블록 채움) */
#ps-boot .boot-gauge {
  width: min(430px, 72vw); height: 24px;
  display: flex; gap: 3px; padding: 3px;
  border: 2px solid var(--titlebar-text);
}
#ps-boot .boot-gauge i { flex: 1; background: transparent; transition: background-color 0.1s linear; }
#ps-boot .boot-gauge i.f { background: var(--accent); }
#ps-boot .boot-stamp {
  font-family: var(--font-hand); font-weight: 700; font-size: 27px; line-height: 1;
  letter-spacing: 3px; color: var(--titlebar-text);
  border: 2.5px solid var(--accent);
  padding: 9px 20px 6px;
  transform: rotate(-7deg) scale(1.7); opacity: 0;
  transition: transform 0.4s var(--ease-pop), opacity 0.2s ease;
}
#ps-boot .boot-stamp.on { transform: rotate(-7deg) scale(1); opacity: 1; }
#ps-boot .boot-hint {
  position: absolute; bottom: 22px; left: 0; right: 0;
  text-align: center;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 2.5px;
  color: rgba(242, 237, 221, 0.45);
}

/* ── 모션 최소화: 부팅/리빌/스탬프 전부 정적으로 ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rv { opacity: 1; transform: none; transition: none; }
  .marker { transition: none; }
  .stamp { transition: none; }
  .card, .btn, .list-card::after, .nav a { transition: none; }
}

/* ── 반응형 ── */
@media (max-width: 640px) {
  .wrap { margin: 12px 12px 44px; padding: 0 16px 40px; box-shadow: 6px 6px 0 var(--shadow); }
  .titlebar { margin: 0 -16px 22px; font-size: 11px; letter-spacing: 1px; padding: 10px 12px; }
  .header-row { padding-top: 18px; }
  .hero { padding: 14px 0 30px; }
  .stamp { font-size: 17px; top: 2px; right: 0; padding: 7px 11px 5px; }
  .card { padding: 18px; box-shadow: 3px 3px 0 var(--shadow); }
  .card:hover { box-shadow: 5px 5px 0 var(--shadow); }
  .cta-band { padding: 26px 18px; box-shadow: 5px 5px 0 var(--shadow); }
  .article { padding: 24px 18px; }
  #ps-boot .boot-log { font-size: 11px; min-height: 104px; }
}
