/**
 * Candy home portal — bridge with existing theme screens / dock.
 * Portal is a .screen: hidden by default, only visible with .move-show
 * (matches firstScreen / archive / category routing).
 */
:root {
  /* 门户 .gray 与全站 #site-bg 共用，离开门户时壁纸亮度不跳变 */
  --candy-wallpaper-vignette:
    radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0.5) 100%),
    radial-gradient(rgba(0, 0, 0, 0) 33%, rgba(0, 0, 0, 0.3) 166%);
}

#index.candy-home {
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
  min-height: 100%;
  min-height: 100dvh;
  min-height: var(--candy-vh, 100dvh);
  overflow: hidden;
  background: transparent;
  color: #fff;
  z-index: 1;
  display: none;
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  transform: none;
  opacity: 1;
  -webkit-transform: translateZ(0);
}

#index.candy-home.move-show {
  display: block !important;
}

/* 壁纸层：不参与 Move 变换，始终铺满视口（类似全局 .bg） */
#index.candy-home > .cover {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#index.candy-home > .cover.show {
  z-index: 2;
  pointer-events: auto;
}

/* 仅内容层做切换动画；idle 时 transform:none，切屏中由 @keyframes 接管（勿写 transform:unset） */
#index.candy-home > #home-move-layer:not([class*="move-animation-"]) {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: transparent;
  transform: none;
  transform-origin: center center;
}

/* 切屏时勿裁切上滑/下滑动画（WAAPI 用 candy-screen-transition-*，CSS fallback 用 move-animation-*） */
#archive.candy-screen-transition,
#archive.move-show[class*="move-animation-"],
#archive[class*="move-animation-"],
#page.candy-screen-transition,
#page.move-show[class*="move-animation-"],
#page[class*="move-animation-"],
#home-more.candy-screen-transition,
#home-more.move-show[class*="move-animation-"],
#home-more[class*="move-animation-"],
#usercenter.candy-screen-transition,
#usercenter.move-show[class*="move-animation-"],
#usercenter[class*="move-animation-"] {
  overflow: visible !important;
}

#index.candy-home.candy-screen-transition,
#index.candy-home:has(> #home-move-layer.candy-screen-transition-in),
#index.candy-home:has(> #home-move-layer.candy-screen-transition-out),
#index.candy-home:has(> #home-move-layer[class*="move-animation-"]) {
  overflow: visible !important;
}

/* 仅内容层铺满；勿用 > div:not(.cover)，会误伤顶层浮层。切屏中勿写 transform */
#index.candy-home > .candy-home-app:not([class*="move-animation-"]):not(.candy-screen-transition-in):not(.candy-screen-transition-out),
#index.candy-home > #home-move-layer:not([class*="move-animation-"]):not(.candy-screen-transition-in):not(.candy-screen-transition-out) {
  margin: 0 !important;
  padding: 0 !important;
  width: 100%;
  height: 100%;
  max-width: none !important;
  transform: none;
}

#index.candy-home > .candy-home-app[class*="move-animation-"],
#index.candy-home > .candy-home-app.candy-screen-transition-in,
#index.candy-home > .candy-home-app.candy-screen-transition-out,
#index.candy-home > #home-move-layer[class*="move-animation-"],
#index.candy-home > #home-move-layer.candy-screen-transition-in,
#index.candy-home > #home-move-layer.candy-screen-transition-out {
  margin: 0 !important;
  padding: 0 !important;
  width: 100%;
  height: 100%;
  max-width: none !important;
}

#index.candy-home .candy-home-app {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 全站同一张壁纸：#site-bg 始终铺底；门户内 #home-bg 是同图副本（毛玻璃糊得到） */
body > .bg#site-bg {
  position: fixed !important;
  inset: 0;
  z-index: 0 !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: none;
  background-image: var(--candy-wallpaper);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* 与全局 .bg 一致：铺满大视口，避免 iOS 下半白屏 */
  width: 100%;
  height: auto;
  min-height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100lvh;
  /* 与门户 .gray 同款暗角，切走门户后壁纸亮度不跳变 */
  overflow: hidden;
}

body > .bg#site-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: var(--candy-wallpaper-vignette);
}

#index.candy-home .cover .bg,
#index.candy-home .cover .cover-photo {
  opacity: 1;
  pointer-events: none;
}

/* 切屏时壁纸/背景保持静止，不参与位移或淡入淡出 */
#index.candy-home > .cover {
  opacity: 1;
  transform: none;
  filter: none;
  pointer-events: none;
}

#index.candy-home > .cover .gray {
  opacity: 1;
}

/* Menu / search overlays sit above content; keep dock above them */
body.home-set-open #candy-dock,
body.nav-open #candy-dock,
body.search-open #candy-dock {
  z-index: 70;
}

#index.candy-home #footer {
  pointer-events: auto;
  z-index: 20;
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
}

#index.candy-home #footer.footer-blur,
#index.candy-home #footer.blur {
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

#index.candy-home #footer .power {
  background: transparent !important;
}

#index.candy-home #home-gray[hidden] {
  display: none !important;
}

#index.candy-home #candy-home-main:not([hidden]) {
  display: block;
}

#index.candy-home #candy-home-main[hidden] {
  display: none !important;
}

#index.candy-home .icon-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  font-size: 12px;
  font-weight: 600;
}

#index.candy-home .home-links-pages {
  --home-links-page-gap: 20px;
  position: relative;
  width: 100%;
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
  outline: none;
}

/* 未就绪 / 停靠：只渲染当前 active 页，避免轨道默认 transform 露出第一页 */
#index.candy-home .home-links-pages:not(.is-links-ready) .home-links-track {
  display: block;
  transform: none !important;
  transition: none !important;
}

#index.candy-home .home-links-pages:not(.is-links-ready) .link-page {
  display: none;
}

#index.candy-home .home-links-pages:not(.is-links-ready) .link-page.is-active {
  display: block;
  width: 100%;
}

#index.candy-home .home-links-pages.is-links-snapping .home-links-track {
  transition: none !important;
}

#index.candy-home .home-links-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  column-gap: var(--home-links-page-gap);
  width: 100%;
  will-change: transform;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  backface-visibility: hidden;
}

#index.candy-home .home-links-track.is-dragging {
  transition: none;
}

#index.candy-home .link-page {
  box-sizing: border-box;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

#index.candy-home .home-links-pages.is-links-dragging {
  cursor: grabbing;
  user-select: none;
  touch-action: none;
}

#index.candy-home .home-links-pages.is-links-dragging .home-site-link {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  #index.candy-home .home-links-track {
    transition: none;
  }
}

#index.candy-home .home-links-dots {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

/* imsyy Swiper pagination bullet bar */
#index.candy-home .home-links-dots .dot {
  width: 20px;
  height: 4px;
  border-radius: 4px;
  border: 0;
  padding: 0;
  margin: 0;
  background-color: #fff;
  opacity: 0.2;
  cursor: pointer;
  transition: opacity 0.3s;
}

#index.candy-home .home-links-dots .dot.is-active,
#index.candy-home .home-links-dots .dot:hover {
  opacity: 1;
}

#index.candy-home .link-all {
  display: flex;
  flex-wrap: wrap;
  row-gap: 20px;
  margin-left: -10px;
  margin-right: -10px;
  height: 220px;
}

#index.candy-home .link-col {
  flex: 0 0 33.3333333333%;
  max-width: 33.3333333333%;
  width: auto;
  padding-left: 10px;
  padding-right: 10px;
  box-sizing: border-box;
}

/* Row layout by default (imsyy); column only ≤460 — overrides prior bridge column force */
#index.candy-home .link-all .item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  height: 100px;
  min-height: 0;
  width: 100%;
  padding: 0 10px;
  text-align: center;
  color: #fff;
  cursor: pointer;
  box-sizing: border-box;
}

#index.candy-home .link-all .item .item-icon {
  font-size: 26px;
  width: 26px;
  height: 26px;
  margin-bottom: 0;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}

#index.candy-home .link-all .item .name {
  font-size: 1.1rem;
  margin-left: 8px;
}

@media (max-width: 720px) {
  #index.candy-home .home-links-pages {
    --home-links-page-gap: 16px;
  }
  #index.candy-home .link-all {
    row-gap: 12px;
    height: 172px;
    margin-left: -6px;
    margin-right: -6px;
  }
  #index.candy-home .link-col {
    padding-left: 6px;
    padding-right: 6px;
  }
  #index.candy-home .link-all .item {
    height: 80px;
    padding: 0 6px;
  }
  #index.candy-home .link-all .item .name {
    font-size: 1rem;
  }
}

@media (max-width: 720px) and (max-height: 700px) {
  #index.candy-home .link-all {
    row-gap: 14px;
    height: 150px;
  }
  #index.candy-home .link-all .item {
    height: 68px;
  }
}

@media (max-width: 460px) {
  #index.candy-home .link-all .item {
    flex-direction: column;
  }
  #index.candy-home .link-all .item .name {
    font-size: 1rem;
    margin-left: 0;
    margin-top: 8px;
  }
  #index.candy-home .link-all .item .item-icon {
    width: 22px;
    height: 22px;
    font-size: 22px;
  }
}

#index.candy-home .func-row {
  display: flex;
  gap: 20px;
}

#index.candy-home .func-col {
  flex: 1;
  min-width: 0;
}

#index.candy-home .set-item {
  margin-bottom: 16px;
}

#index.candy-home .set-item label {
  display: block;
  margin-bottom: 6px;
  color: #efefef;
}

#index.candy-home .set-item select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
}

#index.candy-home .start-page {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  box-sizing: border-box;
}

#index.candy-home .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Ensure start search engine button styles even without iconfont */
#index.candy-home .search-input .all .engine {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 64px;
  font-size: 20px;
  border: 0;
  border-radius: 30px;
  flex-shrink: 0;
  background: none;
  color: inherit;
}

#index.candy-home .search-input .all .engine .i-icon,
#index.candy-home .search-input .all .go .i-icon {
  width: 22px;
  height: 22px;
}

/* Weather removed — keep clock card full height */
#index.candy-home .time-weather .weather,
#index.candy-home #home-weather {
  display: none !important;
}

#index.candy-home .time-weather .time {
  width: 100%;
}

/* Touch-friendly settings hotspot */
@media (max-width: 720px) {
  #index.candy-home .home-set-hotspot {
    width: 52px;
    height: 52px;
    padding: max(10px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 10px 10px;
    box-sizing: border-box;
  }
  #index.candy-home .home-set-icon:not([hidden]) {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
  }
  #index.candy-home .home-set-icon .mdi {
    font-size: 22px;
  }
}

/* Toast moved to CandyUI.notify (.notify-container) */

@keyframes candy-home-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  #index.candy-home .func-row {
    flex-direction: column;
  }
}

/* 门户底部：进入博客提示已移除 */

body.home-set-open #index.candy-home > .home-enter-hint,
body.search-open #index.candy-home > .home-enter-hint {
  display: none !important;
}
