/* ==========================================================================
   phone.css — 手机外壳（T3）
   负责：舞台/手机边框、状态栏、锁屏、桌面 + dock、顶部横幅 toast、头像基础样式
   不负责：缘来 app 内部（css/app.css，T4）
   对 T4 的约定：
     - 变量 --sb-h 是状态栏高度，#app-root 已自带 padding-top: var(--sb-h)
     - #app-root 内容区背景默认白，状态栏在 app 态自动转深色文字
     - 头像用 .avatar / .avatar--sm / .avatar--lg（由 js/avatar.js 生成）
   ========================================================================== */

:root {
  --sb-h: 44px;                    /* 状态栏高度（不含安全区） */
  --phone-w: 390px;
  --phone-h: 844px;
  --font-ui: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;

  /* 夜色壁纸调色板：深灰蓝 + 暖橙暮光。刻意避开 purple/violet/indigo */
  --wall-ink: #0c1319;
  --wall-slate: #1a2530;
  --wall-teal: rgba(52, 108, 108, 0.30);
  --wall-amber: rgba(226, 158, 82, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #15181b;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   舞台与手机
   -------------------------------------------------------------------------- */

#stage {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#phone {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--wall-ink);
  color: #fff;
  font-size: 16px;
  line-height: 1.45;
  isolation: isolate;
}

/* 屏幕层叠：桌面在底，app 在中，锁屏在上 */
#screen-home { z-index: 1; }
#app-root    { z-index: 2; }
#screen-lock { z-index: 3; }
#statusbar   { z-index: 5; }
#toast-layer { z-index: 9; }

#screen-lock, #screen-home, #app-root {
  position: absolute;
  inset: 0;
}

.is-hidden { display: none !important; }

/* 壁纸：多层 radial-gradient，深灰蓝夜色 + 右上暖橙暮光 */
.wallpaper {
  background-color: var(--wall-ink);
  background-image:
    radial-gradient(115% 70% at 80% 8%,  var(--wall-amber), transparent 58%),
    radial-gradient(95% 65% at 12% 92%,  var(--wall-teal),  transparent 62%),
    radial-gradient(60% 40% at 62% 62%,  rgba(255, 255, 255, 0.05), transparent 70%),
    linear-gradient(168deg, var(--wall-slate) 0%, #131c25 46%, var(--wall-ink) 100%);
}

/* 桌面壁纸略压暗，图标标签更清楚 */
#screen-home.wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.10) 0%, rgba(0, 0, 0, 0.02) 40%, rgba(0, 0, 0, 0.28) 100%);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   状态栏
   -------------------------------------------------------------------------- */

#statusbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--sb-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #fff;
  pointer-events: none;
  user-select: none;
}

.sb-time { font-variant-numeric: tabular-nums; }

.sb-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 信号：四格递增 */
.sb-signal {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
}
.sb-signal i {
  display: block;
  width: 3px;
  background: currentColor;
  border-radius: 1px;
  opacity: 1;
}
.sb-signal i:nth-child(1) { height: 4px; }
.sb-signal i:nth-child(2) { height: 6px; }
.sb-signal i:nth-child(3) { height: 8.5px; }
.sb-signal i:nth-child(4) { height: 11px; opacity: 0.35; }

/* Wi-Fi：三段同心弧 + 圆点，纯 CSS */
.sb-wifi {
  position: relative;
  width: 16px;
  height: 11px;
}
.sb-wifi i {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  border: 1.5px solid currentColor;
  border-bottom-color: transparent;
  border-left-color: transparent;
  border-right-color: transparent;
  border-radius: 50%;
}
.sb-wifi i:nth-child(1) { width: 16px; height: 16px; }
.sb-wifi i:nth-child(2) { width: 10px; height: 10px; }
.sb-wifi i:nth-child(3) {
  width: 3.5px;
  height: 3.5px;
  border: none;
  background: currentColor;
  border-radius: 50%;
  bottom: 0.5px;
}

/* 电量 */
.sb-battery {
  position: relative;
  width: 25px;
  height: 12px;
  border: 1.3px solid currentColor;
  border-radius: 3.5px;
  opacity: 0.95;
}
.sb-battery::after {
  content: "";
  position: absolute;
  right: -3.5px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 4px;
  background: currentColor;
  border-radius: 0 1px 1px 0;
  opacity: 0.6;
}
.sb-battery b {
  position: absolute;
  left: 1.5px;
  top: 1.5px;
  bottom: 1.5px;
  width: 72%;
  background: currentColor;
  border-radius: 2px;
}

/* app 态：白底界面下状态栏转深色文字 + 磨砂底 */
#phone[data-screen="app"] #statusbar {
  color: #111214;
  background: rgba(249, 249, 249, 0.86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

/* --------------------------------------------------------------------------
   锁屏
   -------------------------------------------------------------------------- */

#screen-lock {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--sb-h) + env(safe-area-inset-top, 0px) + 46px) 24px 22px;
  touch-action: none;
  cursor: grab;
  transition: transform 0.42s cubic-bezier(0.22, 0.9, 0.24, 1), opacity 0.42s ease;
}
#screen-lock.is-dragging {
  transition: none;
  cursor: grabbing;
}
#screen-lock.is-unlocked {
  transform: translateY(-100%);
  opacity: 0;
}

.lock-clock {
  text-align: center;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}
.lock-date {
  font-size: 17px;
  font-weight: 600;
  opacity: 0.9;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}
.lock-time {
  font-size: 82px;
  font-weight: 200;
  line-height: 1.02;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
}
/* 锁屏中部：一条低调的「工作提醒」卡，交代局内身份，纯 CSS 毛玻璃 */
.lock-note {
  width: 100%;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.lock-note-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(160deg, #e8503f, #bf2419);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 500;
  color: #fff;
}
.lock-note-body { min-width: 0; }
.lock-note-title {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.95;
}
.lock-note-text {
  font-size: 13px;
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lock-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}
.lock-hint {
  font-size: 14px;
  opacity: 0.75;
  letter-spacing: 1px;
  animation: lockHintBreathe 2.4s ease-in-out infinite;
}
.lock-hint-arrow {
  display: block;
  text-align: center;
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 2px;
}
@keyframes lockHintBreathe {
  0%, 100% { opacity: 0.42; transform: translateY(2px); }
  50%      { opacity: 0.88; transform: translateY(-2px); }
}
.home-indicator {
  width: 134px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
}

/* --------------------------------------------------------------------------
   桌面
   -------------------------------------------------------------------------- */

#screen-home {
  display: flex;
  flex-direction: column;
  padding: calc(var(--sb-h) + env(safe-area-inset-top, 0px) + 18px) 18px 14px;
}
#screen-home > * { position: relative; z-index: 1; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px 12px;
  align-content: start;
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 0;
  padding: 0;
  background: none;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.app-icon:active { transform: scale(0.9); opacity: 0.75; }

.app-tile {
  width: 60px;
  height: 60px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3), inset 0 0.5px 0 rgba(255, 255, 255, 0.2);
}
.app-label {
  font-size: 11.5px;
  font-weight: 400;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

/* 各 app 的图案（纯 CSS / emoji，零图片） */
.tile-yuanlai {
  background: linear-gradient(158deg, #ef5b47 0%, #d02c1e 52%, #ab1d12 100%);
  font-size: 31px;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}
.tile-weather   { background: linear-gradient(170deg, #55a7d6, #26688f); }
.tile-photos    { background: linear-gradient(170deg, #ffffff, #f1f1f4); }
.tile-settings  { background: linear-gradient(170deg, #9a9aa0, #5c5c63); }
.tile-calc      { background: linear-gradient(170deg, #3a3a3d, #1c1c1e); }

.tile-calendar {
  background: #fff;
  flex-direction: column;
  gap: 0;
  padding-top: 5px;
}
.tile-calendar .cal-m {
  font-size: 11px;
  font-weight: 600;
  color: #f0453c;
  letter-spacing: 0.5px;
}
.tile-calendar .cal-d {
  font-size: 27px;
  font-weight: 300;
  color: #1c1c1e;
  line-height: 1.06;
  font-variant-numeric: tabular-nums;
}

.tile-notes {
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.10) 0 1px, transparent 1px 9px) 0 20px / 100% calc(100% - 20px) no-repeat,
    linear-gradient(180deg, #fdf1c2 0 19px, #fffdf2 19px);
}
.tile-notes span {
  font-size: 22px;
  margin-top: 14px;
}

/* 页面指示点 */
.home-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: auto;
  padding: 14px 0 16px;
}
.home-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
}
.home-dots i.on { background: rgba(255, 255, 255, 0.95); }

/* dock：毛玻璃 */
.home-dock {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 12px 18px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.14);
  border: 0.5px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.home-dock .app-label { display: none; }

/* --------------------------------------------------------------------------
   app 容器
   -------------------------------------------------------------------------- */

#app-root {
  padding-top: calc(var(--sb-h) + env(safe-area-inset-top, 0px));
  background: #f2f2f7;
  color: #111214;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   toast：iOS 顶部横幅
   -------------------------------------------------------------------------- */

#toast-layer {
  position: absolute;
  top: calc(var(--sb-h) + env(safe-area-inset-top, 0px) + 4px);
  left: 0;
  right: 0;
  padding: 0 10px;
  pointer-events: none;
}

.toast {
  padding: 13px 16px;
  border-radius: 20px;
  background: rgba(32, 34, 37, 0.9);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
  color: #f4f4f6;
  font-size: 14.5px;
  line-height: 1.42;
  transform: translateY(-140%);
  opacity: 0;
  transition: transform 0.38s cubic-bezier(0.2, 0.9, 0.25, 1), opacity 0.28s ease;
}
.toast.is-in {
  transform: translateY(0);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   头像基础样式（内容由 js/avatar.js 注入）
   -------------------------------------------------------------------------- */

.avatar {
  --avatar-size: 44px;
  flex: 0 0 auto;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 4px;                 /* 微信风方角 */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 500;
  font-size: calc(var(--avatar-size) * 0.44);
  line-height: 1;
  letter-spacing: 0;
  user-select: none;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.avatar--sm { --avatar-size: 44px; }
.avatar--md { --avatar-size: 56px; }
.avatar--lg { --avatar-size: 72px; }

/* --------------------------------------------------------------------------
   响应式：≤500px 真手机占满；>500px 居中手机边框
   -------------------------------------------------------------------------- */

@media (min-width: 501px) {
  body {
    /* 低调桌面底色，不用渐变噪点 */
    background:
      radial-gradient(80% 60% at 50% 0%, #23282d 0%, #1a1e22 55%, #141719 100%);
  }

  #stage { padding: 24px; }

  #phone {
    width: var(--phone-w);
    height: var(--phone-h);
    max-height: calc(100dvh - 48px);
    flex: 0 0 auto;
    border-radius: 52px;
    border: 11px solid #17181a;
    box-shadow:
      0 0 0 2px #35373b,
      0 34px 70px rgba(0, 0, 0, 0.6),
      inset 0 0 2px rgba(255, 255, 255, 0.12);
  }

  /* 灵动岛 */
  #phone::before {
    content: "";
    position: absolute;
    top: 11px;
    left: 50%;
    transform: translateX(-50%);
    width: 104px;
    height: 29px;
    border-radius: 16px;
    background: #000;
    z-index: 20;
    pointer-events: none;
  }

  /* 灵动岛占位：状态栏两侧内容让开中间 */
  #statusbar { padding-left: 30px; padding-right: 30px; }
}

@media (max-width: 500px) {
  #stage { align-items: stretch; }
  #phone { border-radius: 0; }
}
