/* ============================================================
   pilgrimage-popo — 圣地巡礼打卡进度组件样式
   全部类名 popo-pg-* 前缀，变量 --popo-* 前缀
   不使用 :has()、container queries、裸 dvh（有 @supports 回退）
   不触碰现有 ui.css 的任何规则
   ============================================================ */

/* ---------- 进度条容器（hero 与 tab-bar 之间） ---------- */
#popoPgProgress {
    /* 与 .pg-hero 标题同宽：只保留上下间距，左右不再内缩 */
    margin: 0 0 16px;
    padding: 16px 18px;
    background: var(--popo-bg);
    border-radius: var(--popo-radius);
    box-shadow: var(--popo-shadow);
    font-family: var(--popo-font);
    animation: popoPgFade 0.3s ease-out;
}
@keyframes popoPgFade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 标题 + 计数的 flex 行 */
.popo-pg-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
}
.popo-pg-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--popo-ink);
    letter-spacing: 0.3px;
}
.popo-pg-count {
    font-size: 15px;
    font-weight: 700;
    color: var(--popo-accent);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.popo-pg-loading {
    font-size: 13px;
    color: var(--popo-ink-muted);
}

/* 进度条轨道 */
#popoPgTrack {
    position: relative;
    height: 8px;
    background: var(--popo-bg-soft);
    border-radius: 999px;
    overflow: visible; /* paw 允许超出轨道 */
}
/* 填充：左深右浅的单色天蓝渐变（参考图沿途取样）
   末端停在淡天蓝而不是参考图那种溶到背景白：3% 时整段填充会被爪子压住，
   照抄会变成「断尾」，还会让 token 蓝的爪子描边显得孤立 */
#popoPgFill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background-color: #95D3FB;
    background-image: linear-gradient(90deg,
        #95D3FB 0%,
        #A0D8FD 40%,
        #BDE2FE 70%,
        #DCEFFF 100%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
/* 爪印——只在进度条末端使用这一处
   形状照参考图：正向朝上、近 1:1（22x23.5），描边约 4% 宽度；
   颜色用 --popo-accent（参考图的天蓝比现有蓝亮，按「协调」取 token） */
#popoPgPaw {
    position: absolute;
    top: 50%;
    width: 22px;
    height: auto;
    transform: translate(-50%, -50%);
    transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(86, 122, 206, 0.22));
}

/* 分类计数行 */
#popoPgSplit {
    margin-top: 10px;
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--popo-ink-soft);
    flex-wrap: wrap;
}
.popo-pg-split-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.popo-pg-split-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--popo-accent);
    opacity: 0.45;
}

/* 访客/错误占位行 */
.popo-pg-guest,
.popo-pg-error {
    margin-top: 12px;
    font-size: 13px;
    color: var(--popo-ink-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.popo-pg-guest a,
.popo-pg-guest button,
.popo-pg-error button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 12px;
    min-height: 32px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    font-family: var(--popo-font);
}
.popo-pg-guest a {
    background: var(--popo-accent-bg);
    color: var(--popo-accent);
}
.popo-pg-guest a:hover { background: var(--popo-accent-hover); }
.popo-pg-error button {
    background: var(--popo-danger);
    color: #fff;
}
.popo-pg-error button:hover { filter: brightness(0.9); }
.popo-pg-spacer { flex: 1; } /* 让按钮靠右（如有需求） */

/* ---------- 卡片徽章（已到达角标） ---------- */
.popo-pg-visited {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 2px 8px;
    font-size: 10.5px;
    font-weight: 700;
    color: #fff;
    background: var(--popo-accent);
    border-radius: 999px;
    letter-spacing: 0.5px;
    line-height: 1.3;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(86, 122, 206, 0.3);
}
.pg-card-img { position: relative; } /* 徽章定位锚点 */

/* ---------- 详情抽屉内的打卡块 ---------- */
.popo-pg-checkin-block {
    margin-bottom: 12px;
    padding: 12px 14px;
    background: var(--popo-accent-bg);
    border-radius: var(--popo-radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-bottom: calc(12px + var(--popo-pg-safe-bottom));
}
.popo-pg-checkin-text {
    flex: 1 1 auto;
    min-width: 0;
}
.popo-pg-checkin-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--popo-accent);
    margin-bottom: 2px;
}
.popo-pg-checkin-hint {
    font-size: 12px;
    color: var(--popo-ink-soft);
}
.popo-pg-checkin-done-at {
    font-size: 12px;
    color: var(--popo-success);
    margin-top: 2px;
}
.popo-pg-checkin-btn {
    flex: 0 0 auto;
    min-height: 44px;           /* 44px 触控目标 */
    padding: 0 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-family: var(--popo-font);
    transition: transform 0.15s, background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    touch-action: manipulation;
}
.popo-pg-checkin-btn:active { transform: scale(0.97); }
.popo-pg-checkin-btn--mark {
    background: var(--popo-accent);
    color: #fff;
}
.popo-pg-checkin-btn--mark:hover { filter: brightness(0.93); }
.popo-pg-checkin-btn--cancel {
    background: transparent;
    color: var(--popo-danger);
    border: 1px solid var(--popo-danger);
}
.popo-pg-checkin-btn--cancel:hover { background: rgba(232, 93, 106, 0.08); }
.popo-pg-checkin-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}
/* 访客模式下：按钮是 <a> */
.popo-pg-checkin-block a.popo-pg-checkin-btn {
    text-decoration: none;
    background: var(--popo-accent);
    color: #fff;
}

/* ---------- Toast ---------- */
#popoPgToast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + var(--popo-pg-safe-bottom));
    transform: translateX(-50%) translateY(120%);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    background: var(--popo-ink);
    color: #fff;
    border-radius: 999px;
    box-shadow: 0 4px 20px rgba(24, 35, 58, 0.25);
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
    opacity: 0;
    white-space: nowrap;
    pointer-events: none;
    font-family: var(--popo-font);
    max-width: calc(100vw - 40px);
    overflow: hidden;
    text-overflow: ellipsis;
}
#popoPgToast.popo-pg-toast-show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
#popoPgToast.popo-pg-toast-ok { background: var(--popo-success); }
#popoPgToast.popo-pg-toast-err { background: var(--popo-danger); }

/* ---------- 移动端适配（≤ 430px） ---------- */
@media (max-width: 430px) {
    #popoPgProgress { margin: 0 0 14px; padding: 14px 14px; }
    .popo-pg-title { font-size: 13px; }
    .popo-pg-count { font-size: 14px; }
    #popoPgPaw { width: 18px; height: auto; }
    .popo-pg-split-item { font-size: 11px; }
    .popo-pg-checkin-btn { min-height: 44px; padding: 0 16px; font-size: 13px; }
    .popo-pg-visited { font-size: 10px; padding: 2px 7px; }
}

/* ---------- 打卡册 / 相册 ---------- */
#pgBookBody { padding: 0 20px 22px; }
.popo-pg-book-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 14px;
    padding: 14px 16px;
    background: var(--popo-bg);
    border-radius: var(--popo-radius);
    box-shadow: var(--popo-shadow);
}
.popo-pg-book-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--popo-ink);
    font-family: var(--popo-font);
}
.popo-pg-book-count {
    font-size: 15px;
    font-weight: 700;
    color: var(--popo-accent);
    font-variant-numeric: tabular-nums;
    font-family: var(--popo-font);
}
.popo-pg-book-login,
.popo-pg-book-retry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;                  /* 44px 触控目标 */
    padding: 0 20px;
    margin-top: 8px;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--popo-font);
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
}
.popo-pg-book-login { background: var(--popo-accent); color: #fff; }
.popo-pg-book-retry { background: var(--popo-danger); color: #fff; }
.popo-pg-book-login:active,
.popo-pg-book-retry:active { transform: scale(0.97); }

.popo-pg-album-title {
    margin: 22px 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--popo-ink);
    font-family: var(--popo-font);
}
.popo-pg-album-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
/* 正方形用 padding-top 兜底，不依赖 aspect-ratio（旧安卓 WebView） */
.popo-pg-album-item {
    position: relative;
    display: block;
    padding: 0;
    border: none;
    border-radius: var(--popo-radius-sm);
    overflow: hidden;
    background: var(--popo-bg-soft);
    box-shadow: var(--popo-shadow);
    cursor: pointer;
    touch-action: manipulation;
}
.popo-pg-album-item::before {
    content: "";
    display: block;
    padding-top: 100%;
}
.popo-pg-album-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.popo-pg-album-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 22px 12px;
    text-align: center;
    font-size: 13px;
    color: var(--popo-ink-muted);
    background: var(--popo-bg);
    border-radius: var(--popo-radius);
    box-shadow: var(--popo-shadow);
    font-family: var(--popo-font);
}
@media (max-width: 430px) {
    #pgBookBody { padding: 0 14px 18px; }
    .popo-pg-book-head { padding: 12px 14px; margin-bottom: 12px; }
    .popo-pg-album-title { margin: 18px 0 10px; font-size: 13px; }
    .popo-pg-album-grid { gap: 6px; }
}


/* 上传前选可见性：私密 / 公开（公开进审核）
   不用 :has()：药丸样式挂在 label 内的 span 上，旧 WebView 也能选中态 */
.popo-pg-photo-vis {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.popo-pg-vis-opt {
    position: relative;
    display: inline-flex;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.popo-pg-vis-opt input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
}
.popo-pg-vis-opt span {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--popo-border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--popo-ink-muted);
}
.popo-pg-vis-opt input:checked + span {
    border-color: var(--popo-accent);
    background: var(--popo-accent-bg);
    color: var(--popo-accent);
    font-weight: 600;
}
.popo-pg-vis-opt input:focus-visible + span {
    outline: 2px solid var(--popo-accent);
    outline-offset: 2px;
}

/* ---------- 打卡照片上传（详情抽屉内） ---------- */
.popo-pg-photo-block {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--popo-border);
}
.popo-pg-photo-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.popo-pg-photo-btn {
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--popo-accent);
    border-radius: 999px;
    background: var(--popo-accent-bg);
    color: var(--popo-accent);
    font-size: 13px;
    font-family: var(--popo-font);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.popo-pg-photo-btn:disabled { opacity: 0.6; }
.popo-pg-photo-hint {
    font-size: 11px;
    color: var(--popo-ink-muted);
    flex: 1 1 140px;
}
.popo-pg-photo-input { display: none; }
.popo-pg-photo-strip {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.popo-pg-photo-item {
    position: relative;
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: var(--popo-radius-sm);
    overflow: hidden;
    background: var(--popo-bg-soft);
}
.popo-pg-photo-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.popo-pg-photo-pending {
    position: absolute;
    left: 0;
    bottom: 0;
    padding: 1px 5px;
    font-size: 10px;
    font-style: normal;
    color: #fff;
    background: rgba(24, 35, 58, 0.55);
    border-top-right-radius: 6px;
}

/* ---------- 打卡册卡片内：本人打卡照缩略图 ---------- */
.pg-card-photo-strip { display: flex; gap: 4px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.pg-card-photo-strip .popo-pg-photo-item {
  width: 44px; height: 44px; border-radius: 4px; overflow: hidden;
  flex: 0 0 44px; display: flex; align-items: center; justify-content: center;
  background: var(--popo-ink-soft, #f0ece0);
}
.pg-card-photo-strip .popo-pg-photo-item img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.popo-pg-photo-more {
  flex: 0 0 auto; align-self: center; padding-left: 2px;
  font-size: 11px; color: var(--popo-ink-muted, #8a877b);
}

/* ---------- 公开照片墙（详情抽屉内，游客可见） ---------- */
.popo-pg-wall {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--popo-border);
}
.popo-pg-wall[hidden] { display: none; }
.popo-pg-wall-title {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--popo-ink-muted);
}
.popo-pg-wall-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.popo-pg-wall-item {
    position: relative;
    display: block;
    padding-top: 100%;
    border-radius: var(--popo-radius-sm);
    overflow: hidden;
    background: var(--popo-bg-soft);
}
.popo-pg-wall-item img {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
@media (min-width: 720px) {
    .popo-pg-wall-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- dvh 回退（旧 Android WebView） ---------- */
@supports (height: 100dvh) {
    /* 如果项目里任何使用 100vh 的弹窗/抽屉，
       我们只对 popo 组件使用 dvh，其余不动 */
}
