/* ============================================================
   홈 화면 추가 안내 창 (공용 부품)                       2026-09-23
   - 테스트 화면(/pwa-install-test)과 알림 페이지(/alarm)가 함께 씁니다.
   - 스마트폰이 익숙하지 않은 분 기준: 큰 글씨(18px 이상), 큰 버튼(52px 이상), 한 번에 한 행동
   - 흰 카드 · 파란 주요 버튼 · 빨간 안내 화살표
   - 다른 화면 위에도 뜨므로 전역 규칙을 쓰지 않습니다. 모든 이름에 pit- 를 붙이고
     기본값은 .pit-overlay 안에서만 다시 정합니다.
   ============================================================ */

:root {
    --pit-bg: #f3f5fa;
    --pit-card: #ffffff;
    --pit-text: #141821;
    --pit-sub: #454d5c;
    --pit-muted: #6f7888;
    --pit-line: #e2e6ee;
    --pit-soft: #f5f7fb;
    --pit-blue: #1f5eff;
    --pit-blue-press: #1447c9;
    --pit-blue-soft: #e8efff;
    --pit-red: #e5192b;
    --pit-green: #127a44;

    /* 노치·홈 바 영역. 지원하지 않는 브라우저에서는 0 입니다. */
    --pit-sa-top: env(safe-area-inset-top, 0px);
    --pit-sa-right: env(safe-area-inset-right, 0px);
    --pit-sa-bottom: env(safe-area-inset-bottom, 0px);
    --pit-sa-left: env(safe-area-inset-left, 0px);
}

/* 안내 창 안의 기본값. 사이트 화면(어두운 글자색·여백 규칙)이 새어 들어오지 않게 여기서 다시 정합니다. */
.pit-overlay,
.pit-overlay *,
.pit-overlay *::before,
.pit-overlay *::after {
    box-sizing: border-box;
}

.pit-overlay {
    color: var(--pit-text);
    font-size: 18px;
    line-height: 1.55;
    text-align: left;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* 버튼·칸에 display 를 주면 브라우저 기본 [hidden] 이 무시됩니다. 항상 숨기도록 고정합니다. */
.pit-overlay[hidden],
.pit-overlay [hidden] {
    display: none !important;
}

.pit-overlay h2,
.pit-overlay p,
.pit-overlay ol,
.pit-overlay figure {
    margin: 0;
}

/* 안내가 열려 있을 때 뒤 화면이 같이 움직이지 않게 합니다. */
html.pit-locked,
html.pit-locked body {
    overflow: hidden;
}

.pit-btn:focus-visible,
.pit-x:focus-visible {
    outline: 3px solid #ffb400;
    outline-offset: 3px;
}

/* ------------------------------------------------------------
   안내 오버레이
   화면을 위(화살표) / 가운데(카드) / 아래(화살표) 세 칸으로 나눕니다.
   화살표 칸이 카드와 같은 흐름에 있어서 카드가 화살표를 가리지 않습니다.
   ------------------------------------------------------------ */
.pit-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background: rgba(12, 16, 28, 0.74);
}

.pit-x {
    position: fixed;
    top: calc(var(--pit-sa-top) + 10px);
    right: calc(var(--pit-sa-right) + 10px);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    color: var(--pit-text);
    cursor: pointer;
}

.pit-x svg {
    width: 26px;
    height: 26px;
}

.pit-zone {
    flex: 0 0 auto;
    display: flex;
    padding-left: calc(var(--pit-sa-left) + 12px);
    padding-right: calc(var(--pit-sa-right) + 12px);
}

/* 위 칸은 화살표가 없어도 닫기 버튼 자리만큼은 비워 둡니다. */
.pit-zone--top {
    align-items: flex-start;
    min-height: calc(var(--pit-sa-top) + 70px);
    padding-top: calc(var(--pit-sa-top) + 8px);
}

.pit-zone--bottom {
    align-items: flex-end;
    min-height: 16px;
    padding-bottom: calc(var(--pit-sa-bottom) + 8px);
}

/*
 * 가운데 칸. 카드가 들어갈 자리보다 크면 카드가 줄어들고(스크롤은 카드 안 설명 부분이 맡음),
 * 작으면 세로 가운데에 놓입니다. 이 칸 자체는 스크롤하지 않습니다.
 */
.pit-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 4px calc(var(--pit-sa-right) + 14px) 8px calc(var(--pit-sa-left) + 14px);
}

.pit-card {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 460px;
    padding: 18px 18px 16px;
    border-radius: 24px;
    background: var(--pit-card);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
    text-align: center;
}

/* 보이는 단계 하나가 카드를 채웁니다. 설명(위)은 줄어들며 스크롤, 버튼(아래)은 항상 제자리. */
.pit-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pit-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/*
 * 아주 작은 화면에서 설명이 넘치면 아래쪽을 흐리게 해 "더 있다" 는 것을 알려줍니다.
 * 스크롤해서 끝에 닿으면 흐림을 걷어냅니다(자바스크립트가 is-more 를 켜고 끔).
 */
.pit-panel-body.is-more {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
}

/* 진행 단계. 제목 줄 끝에 작은 알약으로 붙여 따로 한 줄을 차지하지 않게 합니다. */
.pit-stepno {
    display: inline-block;
    margin-left: 6px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--pit-soft);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--pit-muted);
    vertical-align: 1px;
    white-space: nowrap;
}

.pit-panel-title .pit-stepno:only-child {
    margin-left: 0;
}

.pit-panel-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--pit-blue);
    word-break: keep-all;
}

/* 지금 해야 할 한 가지. 화면에서 가장 크게. */
/* 390px 폭에서 "① 공유 버튼을 눌러주세요" 가 한 줄에 들어가는 크기 */
.pit-main-action {
    font-size: clamp(22px, 6.4vw, 28px);
    font-weight: 900;
    line-height: 1.3;
    word-break: keep-all;
    outline: none;
}

.pit-num {
    color: var(--pit-blue);
}

/* 아이콘과 이름을 가로로 놓아 높이를 아낍니다. 아이콘은 여전히 크게. */
.pit-share-hero {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 0 auto;
    padding: 12px 24px;
    border: 3px solid var(--pit-blue);
    border-radius: 20px;
    background: var(--pit-blue-soft);
    color: var(--pit-blue);
}

.pit-share-svg {
    width: 68px;
    height: 68px;
    fill: none;
    stroke: currentColor;
    stroke-width: 3.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pit-share-svg--md {
    flex: 0 0 auto;
    width: 60px;
    height: 60px;
}

.pit-share-caption {
    font-size: 22px;
    font-weight: 900;
}

.pit-shape-callout {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 3px solid var(--pit-blue);
    border-radius: 18px;
    background: var(--pit-blue-soft);
    color: var(--pit-blue);
    text-align: left;
}

.pit-shape-callout strong {
    font-size: 21px;
    font-weight: 900;
    line-height: 1.35;
    color: var(--pit-text);
    word-break: keep-all;
}

.pit-hint {
    font-size: 18px;
    color: var(--pit-sub);
    word-break: keep-all;
}

.pit-fallback {
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--pit-soft);
    font-size: 18px;
    line-height: 1.5;
    color: var(--pit-sub);
    text-align: left;
    word-break: keep-all;
}

/* 다음에 할 일 미리보기. 지금 할 일보다 확실히 흐리게, 한 줄에 나란히. */
.pit-preview {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 18px;
    margin: 0;
    padding: 10px 4px 0;
    border-top: 1px solid var(--pit-line);
    list-style: none;
    font-size: 18px;
    color: var(--pit-muted);
}

.pit-preview .pit-num {
    color: var(--pit-muted);
}

.pit-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 19px;
    color: var(--pit-sub);
    text-align: left;
}

/* 버튼 줄. 카드 아래에 붙어 있어 설명이 길어도 가려지지 않습니다. */
.pit-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.pit-actions .pit-btn {
    flex: 1 1 0;
    min-width: 0;
}

/* "닫기" 는 짧은 말이라 폭을 줄이고, 주요 버튼에 자리를 더 줍니다. */
.pit-actions .pit-btn--narrow {
    flex: 0 0 32%;
}

.pit-btn {
    width: 100%;
    min-height: 58px;
    padding: 12px 18px;
    border-radius: 16px;
    font-family: inherit;
    font-size: 21px;
    font-weight: 800;
    cursor: pointer;
    touch-action: manipulation;
}

.pit-btn--primary {
    border: 0;
    background: var(--pit-blue);
    color: #ffffff;
}

.pit-btn--primary:active {
    background: var(--pit-blue-press);
}

.pit-btn--ghost {
    border: 2px solid var(--pit-line);
    background: #ffffff;
    color: var(--pit-text);
}

.pit-btn--ghost:active {
    background: var(--pit-soft);
}

.pit-copied {
    font-size: 18px;
    font-weight: 700;
    color: var(--pit-green);
}

/* 2단계 순서(공유 → 홈 화면에 추가 → 추가). 한 줄로 짧게, 지금 찾을 것만 빨간색. */
.pit-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 26px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pit-flow-item {
    position: relative;
    padding: 4px 10px;
    border: 2px solid var(--pit-line);
    border-radius: 12px;
    background: var(--pit-soft);
    font-size: 18px;
    font-weight: 800;
    line-height: 1.4;
    white-space: nowrap;
}

/* 항목 사이의 ▶ (빨간 삼각형) */
.pit-flow-item + .pit-flow-item::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -19px;
    margin-top: -7px;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 11px solid var(--pit-red);
}

.pit-flow-item--focus {
    border: 3px solid var(--pit-red);
    background: #fff1f2;
    color: var(--pit-red);
}

/*
 * 공유 메뉴 안에서 할 일(②③). 공유 메뉴가 열리면 이 카드가 가려지므로,
 * 찾아야 할 버튼을 실제 iPhone 화면을 잘라 만든 그림으로 미리 보여줍니다.
 */
.pit-next {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--pit-line);
}

.pit-next-text {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--pit-text);
    word-break: keep-all;
}

.pit-next-text strong {
    color: var(--pit-red);
}

/* 예시 그림. 왼쪽 위 "예시" 표시가 그림 속 아이콘을 가리지 않도록 그림 위로 살짝 올립니다. */
.pit-example {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    max-width: 270px;
    margin: 12px auto 0;
}

.pit-example--menu {
    max-width: 340px;
}

.pit-example-img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
    box-shadow: 0 0 0 3px var(--pit-red), 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* 목록 그림은 빨간 테두리가 그림 안에 들어 있어 바깥 테두리는 두지 않습니다. */
.pit-example--menu .pit-example-img {
    border-radius: 16px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.pit-example-tag {
    position: absolute;
    top: -16px;
    left: -6px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--pit-red);
    color: #ffffff;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.4;
}

/* 안드로이드: 메뉴에서 찾을 글자. 실제 화면 그림이 없어 글자만 메뉴 한 줄처럼 보여줍니다. */
.pit-menu-item {
    padding: 8px 16px;
    border: 3px solid var(--pit-red);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    font-size: 20px;
    font-weight: 800;
    line-height: 1.35;
    color: var(--pit-text);
    word-break: keep-all;
}

.pit-menu-alt {
    font-size: 18px;
    line-height: 1.35;
    color: var(--pit-muted);
    word-break: keep-all;
}

/*
 * 설명 묶음. 세로 화면에서는 묶음이 없는 것처럼(자식이 카드 안에 위아래 한 줄로) 동작하고,
 * 가로 화면에서만 좌우 두 칸으로 나뉩니다(맨 아래 가로 화면 규칙).
 */
.pit-col {
    display: contents;
}

/* ------------------------------------------------------------
   가장자리 빨간 화살표
   ------------------------------------------------------------ */
.pit-edge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pit-edge--column {
    flex-direction: column;
    gap: 4px;
}

.pit-edge--row {
    flex-direction: row;
}

.pit-edge--bottom-center {
    margin: 0 auto;
}

/* 오른쪽 위는 닫기 버튼(오른쪽 10px + 52px)과 겹치지 않게 비켜 둡니다. */
.pit-edge--top-right {
    margin-left: auto;
    margin-right: 66px;
}

/* 위를 가리키는 화살표 아래에 설명을 받칩니다. 옆으로 늘어놓을 폭이 없을 때 씁니다. */
.pit-edge--stack-up {
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 2px;
}

.pit-edge--bottom-right {
    margin-left: auto;
    margin-right: 8px;
}

.pit-edge-label {
    padding: 8px 14px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    font-size: 20px;
    font-weight: 900;
    line-height: 1.3;
    color: var(--pit-red);
    word-break: keep-all;
}

/* Chrome 의 위·아래 안내. 닫기 버튼 옆 좁은 자리에 한 줄로 들어가도록 여백을 줄입니다. */
.pit-edge-label--sm {
    padding: 6px 10px;
    font-size: 18px;
    white-space: nowrap;
}

.pit-arrow {
    flex: 0 0 auto;
    width: 60px;
    height: 78px;
    fill: var(--pit-red);
    stroke: #ffffff;
    stroke-width: 3;
    stroke-linejoin: round;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
}

.pit-arrow--sm {
    width: 42px;
    height: 55px;
}

/* 약 0.9초 주기로 가리키는 방향으로 살짝 움직입니다. 과하지 않게 8px 만. */
.pit-arrow--down {
    animation: pit-bob-down 0.9s ease-in-out infinite;
}

.pit-arrow--up {
    animation: pit-bob-up 0.9s ease-in-out infinite;
}

@keyframes pit-bob-down {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

@keyframes pit-bob-up {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/*
 * "동작 줄이기" 를 켠 사용자에게는 위치를 움직이지 않습니다.
 * 대신 천천히 흐려졌다 진해지게 해서 어디를 봐야 하는지는 계속 알려줍니다.
 */
@media (prefers-reduced-motion: reduce) {
    .pit-arrow--down,
    .pit-arrow--up {
        animation: pit-pulse 1.6s ease-in-out infinite;
    }
}

@keyframes pit-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ------------------------------------------------------------
   작은 화면 / 가로 화면
   글씨는 18px 아래로 줄이지 않습니다. 줄이는 것은 아이콘·화살표·여백뿐입니다.
   ------------------------------------------------------------ */

/* 아이폰 SE(375px) 폭에서 Safari 아래 안내가 한 줄에 들어가도록 */
@media (max-width: 389px) {
    .pit-edge-label {
        padding: 6px 10px;
        font-size: 18px;
    }
}

/* 폭이 좁으면 버튼 두 개를 위아래로. 주요 버튼이 위에 오게 뒤집습니다. */
@media (max-width: 359px) {

    .pit-card {
        padding: 16px 14px 14px;
    }

    .pit-actions {
        flex-direction: column-reverse;
    }

    .pit-actions .pit-btn--narrow {
        flex: 0 0 auto;
    }

    .pit-edge--top-right {
        margin-right: 56px;
    }

    /* 아주 좁은 화면에서는 한 줄을 고집하면 화면 밖으로 나가므로 줄바꿈을 허용합니다. */
    .pit-edge-label--sm {
        white-space: normal;
    }
}

/*
 * 실제 아이폰 Safari 는 주소창·도구 막대 때문에 보이는 높이가 기기 화면보다 180px 가량 작습니다.
 * (예: 390×844 기기 → 약 390×664, Pro Max 430×932 → 약 430×739) 대부분의 아이폰이 이 구간에 들어옵니다.
 */
@media (max-height: 760px) {
    /* 닫기 버튼(위 10px + 52px)이 차지하는 만큼만 남깁니다. */
    .pit-zone--top {
        min-height: calc(var(--pit-sa-top) + 62px);
    }

    .pit-arrow {
        width: 44px;
        height: 56px;
    }

    .pit-hint,
    .pit-fallback {
        line-height: 1.35;
    }

    .pit-stage {
        padding-top: 2px;
        padding-bottom: 4px;
    }

    .pit-card {
        padding: 16px 16px 14px;
    }

    .pit-panel {
        gap: 8px;
    }

    .pit-panel-body {
        gap: 6px;
    }

    /* Safari 아래 화살표는 설명 바로 아래 "가운데" 에 둡니다(공유 버튼이 아래 가운데라서).
       설명과 화살표 사이만 좁혀 높이를 아낍니다. */
    .pit-edge--column {
        gap: 0;
    }

    .pit-share-hero {
        padding: 8px 18px;
    }

    .pit-share-svg {
        width: 52px;
        height: 52px;
    }

    .pit-share-svg--md {
        width: 50px;
        height: 50px;
    }

    .pit-next {
        gap: 6px;
        padding-top: 8px;
    }

    .pit-example {
        max-width: 250px;
        margin-top: 10px;
    }

    .pit-example--menu {
        max-width: 330px;
    }
}

/* 아이폰 SE 처럼 더 낮은 화면 */
@media (max-height: 600px) {
    .pit-card {
        padding: 14px 14px 12px;
    }

    .pit-arrow {
        width: 42px;
        height: 54px;
    }

    .pit-arrow--sm {
        width: 34px;
        height: 44px;
    }

    .pit-edge-label {
        padding: 5px 12px;
        font-size: 18px;
    }

    .pit-share-hero {
        padding: 4px 16px;
    }

    .pit-share-svg {
        width: 40px;
        height: 40px;
    }

    .pit-fallback {
        padding: 6px 10px;
    }

    .pit-example {
        max-width: 220px;
        margin-top: 8px;
    }

    /* 목록 그림은 글씨가 작아지므로 덜 줄입니다. */
    .pit-example--menu {
        max-width: 300px;
    }

    .pit-example-tag {
        top: -14px;
    }

    .pit-btn {
        min-height: 54px;
    }
}

/* 가로로 눕히면 세로가 아주 좁습니다. 화살표 설명을 화살표 옆으로 붙여 높이를 아낍니다. */
@media (max-height: 500px) {

    /* 안내 카드: 가로 폭을 넓혀 줄바꿈을 줄입니다. */
    .pit-card {
        max-width: 640px;
    }

    .pit-zone--top {
        min-height: calc(var(--pit-sa-top) + 62px);
    }

    .pit-edge--column,
    .pit-edge--stack-up {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .pit-arrow {
        width: 36px;
        height: 46px;
    }

    .pit-arrow--sm {
        width: 30px;
        height: 38px;
    }

    .pit-btn {
        min-height: 52px;
    }
}

/*
 * 가로 화면: 세로가 낮아 위아래로 쌓으면 예시 그림이 아래로 밀려 보이지 않습니다.
 * 왼쪽에 "지금 할 일", 오른쪽에 "그다음 할 일(예시 그림)" 을 나란히 둡니다.
 */
@media (max-height: 500px) and (min-width: 560px) {
    /* 두 칸이 되므로 카드를 가로로 더 넓게 씁니다(닫기 버튼·화살표는 카드 밖 위아래 띠에 있음). */
    .pit-card {
        max-width: 780px;
    }

    .pit-main-action {
        font-size: 24px;
    }

    .pit-panel-body--split {
        flex-direction: row;
        align-items: flex-start;
        gap: 18px;
    }

    .pit-panel-body--split > .pit-col,
    .pit-panel-body--split > .pit-next {
        display: flex;
        flex-direction: column;
        flex: 1 1 0;
        min-width: 0;
        gap: 6px;
    }

    .pit-panel-body--split > .pit-next,
    .pit-panel-body--split > .pit-col--side {
        align-self: stretch;
        justify-content: center;
        padding: 0 0 0 18px;
        border-top: 0;
        border-left: 1px solid var(--pit-line);
    }
}

/* 노치·홈 바 크기를 재기 위한 측정용 요소 */
.pit-sa-probe {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    visibility: hidden;
    pointer-events: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
