/* ============================================================
   首页 —— 全幅绘本背景 + 五个角色入口
   布局尺寸与原作保持同一套比例关系
   ============================================================ */

body.home {
  background: #a7cf81;
  overflow: hidden;
}

.home-screen {
  --home-gap: clamp(8px, .65vw, 18px);
  --home-gutter: max(3vw, var(--game-safe-left), var(--game-safe-right));
  --portal-row-width: calc(100vw - 2 * var(--home-gutter));
  --portal-width-limited-height: calc((var(--portal-row-width) - 4 * var(--home-gap)) / 5 * 1.5);
  --portal-height: min(58vh, var(--portal-width-limited-height));
  --title-h: clamp(74px, 19vh, 400px);
  --home-top: max(calc(max(56px, 5.5vh) + var(--title-h) + 22px), calc(88% - var(--portal-height)));

  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: #a7cf81;
}

.home-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  user-select: none;
  pointer-events: none;
  z-index: 0;
}

.home-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(#fff8d50d, transparent 55%, #47733d1a);
}

/* ---------- 左上角品牌 ---------- */

.home-logo {
  position: absolute;
  z-index: 4;
  top: max(12px, var(--game-safe-top));
  left: max(2%, var(--game-safe-left));
  width: clamp(66px, 10vw, 320px);
  max-height: 23%;
  filter: drop-shadow(0 3px 5px #1a4e4026);
}
.home-logo img { width: 100%; height: auto; object-fit: contain; }

/* ---------- 中央木牌标题 ---------- */

.home-title {
  position: absolute;
  z-index: 3;
  top: max(56px, 5.5vh);
  left: 50%;
  transform: translateX(-50%);
  width: clamp(230px, 42vw, 1180px);
  height: var(--title-h);
  display: grid;
  place-items: center;
  background: url('/assets/brand/home-title-v2.webp') center / contain no-repeat;
  pointer-events: none;
}
.home-title strong {
  margin-top: 4%;
  font-size: clamp(22px, 3.2vw, 100px);
  font-weight: 900;
  letter-spacing: .08em;
  line-height: 1.25;
  color: #fff8d9;
  text-shadow: 0 2px 0 #8b4e27, 0 3px 4px #69402166;
}

/* ---------- 右上角工具 ---------- */

.home-tools {
  position: fixed;
  z-index: 20;
  top: max(10px, var(--game-safe-top));
  right: max(14px, var(--game-safe-right));
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(100vw - 28px);
}

.tool-btn {
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: #ffffffee;
  color: #26382c;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 4px 12px #1d3b2c1f;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  backdrop-filter: blur(6px);
}
.tool-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px #1d3b2c2e; }
.tool-btn--gold {
  background: linear-gradient(180deg, #ffd76c, #f6bb37);
  color: #5b4109;
  box-shadow: 0 4px 12px #a97c1138;
}
.tool-btn[aria-pressed="false"] { opacity: .72; }

/* ---------- 五个入口 ---------- */

.home-portals {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: var(--home-top);
  transform: translateX(-50%);
  width: calc(var(--portal-height) / 1.5 * 5 + var(--home-gap) * 4);
  max-width: var(--portal-row-width);
  height: var(--portal-height);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--home-gap);
  align-items: end;
  touch-action: manipulation;
}

.portal {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  border-radius: 18%;
  -webkit-tap-highlight-color: transparent;
}
.portal-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 8px 6px #254f3420);
  transition: filter .18s ease, transform .18s ease;
}
.portal:hover .portal-art,
.portal:focus-visible .portal-art {
  filter: drop-shadow(0 11px 9px #1f503449) brightness(1.04);
  transform: translateY(-3px);
}
.portal:active .portal-art { filter: brightness(.96); }
.portal:focus-visible {
  outline: 3px solid #fff5b2;
  outline-offset: 2px;
  background: #fff3;
  border-radius: 18%;
}

.portal-copy {
  position: absolute;
  inset: auto 3% 5.1%;
  height: 8%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.portal-copy strong {
  position: static;
  transform: translateY(-.08em);
  font-size: clamp(11px, 1.55vw, 48px);
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: .02em;
  color: #38583d;
  white-space: nowrap;
  text-shadow: 0 1px 0 #fff7dd;
}

/* 每个角色底座上的白牌位置略有差异，跟着微调 */
.portal:nth-child(2) .portal-copy { bottom: 4.6%; }
.portal:nth-child(3) .portal-copy { bottom: 5.6%; }
.portal:nth-child(4) .portal-copy { bottom: 5.4%; }
.portal:nth-child(5) .portal-copy { bottom: 4.3%; }

/* ---------- 右下角家长中心 ---------- */

.parent-corner {
  position: fixed;
  z-index: 20;
  right: max(16px, var(--game-safe-right));
  bottom: max(18px, var(--game-safe-bottom));
  min-height: 44px;
  padding: 9px 20px;
  border: 0;
  border-radius: 999px;
  background: #ffffffee;
  color: #2b3d31;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px #1d3b2c26;
}
.parent-corner:hover { box-shadow: 0 8px 18px #1d3b2c33; }

/* ---------- 手机竖屏：改为可滚动的两列 ---------- */

.rotate-tip { display: none; }

@media (orientation: portrait) and (max-width: 820px) {
  body.home { overflow: auto; background: #cfe6b1; }

  .home-screen {
    position: relative;
    inset: auto;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 4px;
    padding: max(10px, env(safe-area-inset-top)) 10px max(20px, env(safe-area-inset-bottom));
    overflow: visible;
  }
  .home-backdrop { position: fixed; inset: 0; height: 100dvh; object-position: 62% center; }

  .home-tools {
    position: relative;
    top: auto;
    right: auto;
    grid-row: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    justify-items: stretch;
  }
  .tool-btn { width: 100%; font-size: 13px; }

  .home-logo {
    position: relative;
    top: auto;
    left: auto;
    grid-row: 2;
    width: 108px;
    margin: 4px 0 0 2px;
    justify-self: start;
  }

  .home-title {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    grid-row: 3;
    justify-self: center;
    width: min(78%, 320px);
    height: 96px;
    margin-top: -14px;
  }
  .home-title strong { font-size: 26px; }

  .home-portals {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    grid-row: 4;
    width: 100%;
    max-width: 100%;
    height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
    margin-top: 6px;
  }
  .portal { aspect-ratio: 2 / 3; height: auto; }
  .portal-copy strong { font-size: clamp(15px, 4vw, 19px); }

  .parent-corner { position: relative; right: auto; bottom: auto; justify-self: center; margin-top: 14px; z-index: 20; }

  .rotate-tip {
    display: block;
    position: relative;
    margin: 0 0 18px;
    text-align: center;
    color: #20402f;
    font-size: 13px;
    font-weight: 700;
    opacity: .8;
  }
}

/* 矮屏横版（如 720p 笔记本）收紧标题 */
@media (orientation: landscape) and (max-height: 620px) {
  .home-title { top: max(40px, 4vh); }
  .home-title strong { font-size: clamp(20px, 2.6vw, 44px); }
  .home-logo { width: clamp(58px, 7vw, 180px); }
  .tool-btn { min-height: 40px; padding: 6px 12px; font-size: 12.5px; }
}
