/* 铜傀儡养成站 · 全局样式 */

/* 全站字体：Minecraft（像素风，含 6 万余字形：拉丁 + 全部汉字 + 中文标点 + 假名）
   由官方 TTF 转 WOFF2，16.2MB → 1.5MB */
@font-face {
  font-family: 'Minecraft';
  src: url('/assets/fonts/Minecraft.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --mc-green: #5a8c38;
  --mc-green-dark: #3d5e24;
  --mc-dirt: #6b4f2c;
  --mc-dirt-dark: #4a351a;
  --mc-stone: #7d7d7d;
  --mc-copper: #b87333;
  --mc-copper-light: #d9945a;
  --mc-copper-dark: #8a4e1e;
  --mc-exposed: #8a9a7a;
  --mc-weathered: #6a8a8a;
  --mc-oxidized: #4f9a8a;
  --mc-wax: #f4c430;
  --mc-gold: #f4c430;
  --mc-red: #c13e3e;
  --mc-text: #3b2415;
  --mc-bg: #1e1e1e;
  --panel: #2d2d2d;
  --panel-light: #3a3a3a;
  /* 字体栈：Minecraft 优先；万一字体加载失败，回退到各平台的中文无衬线字体 */
  --font-mc: 'Minecraft', 'Noto Sans SC', 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;   /* 移动端浏览器地址栏收起时高度更准 */
  font-family: var(--font-mc);
  color: #f5f0e6;
  /* 锈蚀铜格栅纹理背景（weathered copper grate），叠加深色遮罩保证文字可读 */
  background:
    linear-gradient(rgba(0,0,0,0.45), rgba(0,0,0,0.45)),
    url('/assets/golem/texture-bg.png');
  background-size: 100% 100%, 480px 270px;
  background-position: 0 0, 0 0;
  background-attachment: fixed, fixed;
  image-rendering: pixelated;
}

body {
  overflow-x: hidden;                 /* 防止小屏横向溢出 */
  -webkit-text-size-adjust: 100%;     /* iOS 横屏不放大字号 */
  text-size-adjust: 100%;
}

/* 表单控件不会自动继承字体，必须显式指定 */
button, input, select, textarea {
  font-family: inherit;
}

/* 像素字体在小字号下略小，整体抬高一点基准字号让观感与之前的无衬线体一致 */
body { font-size: 17px; line-height: 1.55; }

.pixel-font {
  font-family: var(--font-mc);
  letter-spacing: 1px;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* 顶部导航 */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(30,22,15,0.92);
  border-bottom: 4px solid var(--mc-copper-dark);
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  flex-wrap: wrap;
}

.navbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.4rem; font-weight: 700; color: var(--mc-copper-light);
  text-decoration: none;
  min-width: 0;
}

.navbar .brand img { height: 36px; image-rendering: pixelated; flex: 0 0 auto; }

.navbar nav { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  min-height: 40px;               /* 触屏可点区域 */
  border: 2px solid #000;
  border-radius: 0;
  font-size: 0.95rem; font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--mc-stone);
  box-shadow: inset -2px -2px 0 rgba(0,0,0,0.4), inset 2px 2px 0 rgba(255,255,255,0.2);
  transition: transform .05s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;              /* 去掉移动端 300ms 点击延迟 */
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-copper { background: var(--mc-copper); border-color: var(--mc-copper-dark); }
.btn-copper:hover { background: var(--mc-copper-light); }

.btn-green { background: var(--mc-green); border-color: var(--mc-green-dark); }
.btn-green:hover { background: #6aa844; }

.btn-gold { background: #c9a020; border-color: #8f7114; }
.btn-gold:hover { background: var(--mc-gold); color: #3b2415; }

.btn-red { background: var(--mc-red); border-color: #822828; }

.btn-small { padding: 4px 8px; font-size: 0.85rem; min-height: 34px; }

/* 卡片 */
.card {
  background: var(--panel);
  border: 3px solid #000;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,0.4), inset 3px 3px 0 rgba(255,255,255,0.08);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 12px;
  color: var(--mc-copper-light);
  font-size: 1.2rem;
  border-bottom: 2px solid var(--mc-copper-dark);
  padding-bottom: 6px;
}

.card h3 { margin: 0 0 10px; color: #f5f0e6; font-size: 1.05rem; }

/* 表单 */
.form-group { margin-bottom: 12px; }
label { display: block; margin-bottom: 4px; font-size: 0.9rem; color: #ddd; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: #1a1a1a;
  border: 2px solid #555;
  color: #f5f0e6;
  font-size: 1rem;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--mc-copper); }

.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
/* 像素字体更宽，允许输入框收缩，避免把同一行的按钮挤出去 */
.form-actions input, .form-actions select { min-width: 0; }

.message {
  padding: 10px 12px;
  border: 2px solid #000;
  margin-bottom: 12px;
  font-size: 0.95rem;
}
.message.ok { background: rgba(90,140,56,0.3); border-color: var(--mc-green); color: #c6ffab; }
.message.err { background: rgba(193,62,62,0.25); border-color: var(--mc-red); color: #ffcfcf; }

/* 首页 */
.hero {
  display: flex; flex-wrap: wrap; align-items: center; gap: 24px;
  padding: 24px 0;
}
.hero-text { flex: 1 1 320px; }
.hero-text h1 {
  font-size: 2.4rem; color: var(--mc-copper-light); margin: 0 0 12px;
  text-shadow: 3px 3px 0 #000;
}
.hero-text p { font-size: 1.05rem; line-height: 1.6; color: #f0e8d8; }
.hero-img { flex: 0 0 220px; text-align: center; }
.hero-img img { max-height: 300px; image-rendering: pixelated; filter: drop-shadow(4px 4px 0 rgba(0,0,0,0.5)); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tab { padding: 8px 14px; cursor: pointer; border: 2px solid #000; background: var(--panel-light); }
.tab.active { background: var(--mc-copper); color: #fff; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* 资源栏 */
.resource-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
}
.resource {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 2px solid #000;
  background: rgba(20,15,10,0.85); font-weight: 700;
}
.resource img { width: 24px; height: 24px; image-rendering: pixelated; }

/* 铜傀儡展示 */
.golem-arena {
  position: relative;
  /* 高度跟随宽度自适应：手机上不会被压扁，桌面上限 340px */
  height: clamp(210px, 34vw, 340px);
  /* 默认背景：Minecraft 村庄场景（含铜傀儡），叠一层轻微暗化保证文字可读 */
  background:
    linear-gradient(rgba(0,0,0,0.15), rgba(0,0,0,0.3)),
    url('/assets/golem/arena-bg.jpg') center / cover no-repeat;
  border: 4px solid #000;
  overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  /* --ground：傀儡脚底离展示区底边的高度；--body-h：傀儡「站立」时的身体视觉高度 */
  --ground: clamp(8px, 2vw, 14px);
  --body-h: clamp(84px, 13vw, 140px);
}

.golem-stage-label {
  position: absolute; top: 10px; left: 12px;
  padding: 4px 8px; background: rgba(0,0,0,0.65);
  border: 2px solid #000; font-size: 0.85rem; z-index: 2;
}

.golem-wax-badge {
  position: absolute; top: 10px; right: 12px;
  display: none; align-items: center; gap: 4px;
  padding: 4px 8px; background: var(--mc-wax); color: #3b2415;
  border: 2px solid #000; font-size: 0.8rem; font-weight: 700; z-index: 2;
}
.golem-wax-badge.show { display: inline-flex; }
.golem-wax-badge img { width: 20px; height: 20px; image-rendering: pixelated; }

.golem {
  position: absolute; bottom: var(--ground);
  left: 50%;
  height: var(--body-h); width: auto;
  image-rendering: pixelated;
  filter: drop-shadow(4px 6px 0 rgba(0,0,0,0.4));
  transform: translateX(-50%);
  transition: left 2.6s linear;
  will-change: left, bottom;
  z-index: 1;
}

/* 行走素材实测：画面 500x500，站立姿态内容高 383px、跨步最深到 426px，
   脚底线（17 帧中位）在 y=467，内容水平中心在 50.9%。
   ① 元素高度 = body-h × 500/383 ≈ 1.3055，让「头到脚」的视觉高度与静态图完全一致；
   ② 元素底边下移 33/500（= 6.6%）使脚底线正好落在地面线上，走路不陷进地里也不悬空；
   ③ 水平左移 0.9% 抵消素材内容相对画面中心的偏移。 */
.golem.walking {
  height: calc(var(--body-h) * 1.3055);
  bottom: calc(var(--ground) - var(--body-h) * 0.0862);
  transform: translateX(calc(-50% - 0.9%));
}

/* 素材原生朝左；只有向右走时才水平翻转，停下后保持最后朝向 */
.golem.face-right { transform: translateX(-50%) scaleX(-1); }
.golem.walking.face-right { transform: translateX(calc(-50% + 0.9%)) scaleX(-1); }

/* 铜傀儡脚下的阴影 */
.golem-shadow {
  position: absolute; bottom: calc(var(--ground) - 6px); left: 50%;
  width: calc(var(--body-h) * 0.48); height: calc(var(--body-h) * 0.072);
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  transform: translateX(-50%);
  transition: left 2.6s linear;
  will-change: left;
  z-index: 0;
  pointer-events: none;
}

/* 涂蜡后的一层蜜蜡光泽 */
.golem-arena.waxed .golem {
  filter: drop-shadow(4px 6px 0 rgba(0,0,0,0.4)) drop-shadow(0 0 10px rgba(244,196,48,0.85)) saturate(1.15);
}

/* 名牌跟着铜傀儡走，挂在头顶上方（不会挡住身体） */
.golem-name {
  position: absolute;
  bottom: calc(var(--ground) + var(--body-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7); padding: 3px 9px; border: 2px solid #000;
  font-size: clamp(0.72rem, 1.6vw, 0.9rem);
  font-weight: 700; white-space: nowrap; z-index: 2;
  pointer-events: none;
  transition: left 2.6s linear;
  will-change: left;
}

/* 氧化进度条 */
.oxide-bar-wrap {
  margin-top: 12px;
  background: #1a1a1a; border: 2px solid #000; padding: 4px;
}
.oxide-bar {
  height: 22px;
  background: linear-gradient(90deg, var(--mc-copper) 0%, var(--mc-exposed) 33%, var(--mc-weathered) 66%, var(--mc-oxidized) 100%);
  width: 0%; transition: width 0.5s;
}

/* 两栏布局（好友 / 商店），窄屏自动堆叠 */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

/* 商店 / 好友列表 */
.shop-grid, .friends-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.shop-item {
  background: var(--panel-light); border: 2px solid #000; padding: 12px; text-align: center;
}
.shop-item img { width: 48px; height: 48px; image-rendering: pixelated; }
.shop-item .price { color: var(--mc-gold); font-weight: 700; }

.friend-card {
  background: var(--panel-light); border: 2px solid #000; padding: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}

/* 管理员表格（小屏横向滚动，不撑破页面） */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.admin-table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
  min-width: 560px;               /* 配合外层横向滚动，保持列可读 */
}
table.admin-table th, table.admin-table td {
  border: 2px solid #000; padding: 8px; text-align: left;
  white-space: nowrap;
}
table.admin-table th { background: var(--panel-light); position: sticky; top: 0; }

/* 访问好友 */
.visit-banner {
  background: var(--mc-copper); color: #fff; padding: 8px 12px; border: 2px solid #000;
  margin-bottom: 12px; font-weight: 700;
}

/* 帮助文字 */
.help-text { color: #bbb; font-size: 0.9rem; line-height: 1.5; }

/* 页脚 */
.footer { text-align: center; padding: 20px; color: #bbb; font-size: 0.85rem; }

/* ============ 响应式 / 移动端适配 ============ */

/* 平板及以下：两栏布局改为单栏 */
@media (max-width: 700px) {
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .two-col > .card { margin-bottom: 16px; }
}

@media (max-width: 640px) {
  .container { padding: 12px; }

  .card { padding: 12px; margin-bottom: 12px; }
  .card h2 { font-size: 1.1rem; }

  /* 导航：品牌独占一行，资源栏与按钮换行排列 */
  .navbar { gap: 8px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .navbar .brand { font-size: 1.1rem; gap: 8px; flex: 1 1 100%; }
  .navbar .brand img { height: 28px; }
  .navbar .resource-bar { flex: 1 1 auto; margin: 0; gap: 6px; }
  .navbar nav { flex: 1 1 auto; justify-content: flex-end; gap: 6px; }

  .resource { padding: 4px 8px; font-size: 0.9rem; gap: 4px; }
  .resource img { width: 20px; height: 20px; }

  .btn { padding: 8px 12px; min-height: 42px; font-size: 0.95rem; }
  .btn-small { min-height: 36px; }

  /* 首页 hero */
  .hero { gap: 12px; padding: 12px 0; }
  .hero-text h1 { font-size: 1.7rem; margin-bottom: 8px; }
  .hero-text p { font-size: 0.98rem; }
  .hero-img { flex: 1 1 100%; }
  .hero-img img { max-height: 180px; }

  /* 登录/注册选项卡：窄屏可横向滑动，不挤压 */
  .tabs { gap: 2px; }
  .tab { padding: 8px 10px; font-size: 0.9rem; flex: 1; text-align: center; }

  /* 展示区：高度走 clamp，名牌与标签字号同步缩小 */
  .golem-stage-label, .golem-wax-badge { font-size: 0.75rem; padding: 3px 6px; }
  .golem-wax-badge img { width: 16px; height: 16px; }

  .oxide-bar { height: 16px; }
  .oxide-bar-wrap { margin-top: 10px; }

  /* 按钮组：允许按钮撑满一行，方便拇指点按 */
  .form-actions { flex-wrap: wrap; }
  .form-actions > .btn { flex: 1 1 auto; }

  .visit-banner { font-size: 0.9rem; }
  .verify-banner { font-size: 0.9rem; gap: 8px; }
  .verify-banner .btn { flex: 1 1 100%; }

  .shop-grid, .friends-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .shop-item img { width: 40px; height: 40px; }

  .footer { padding: 16px 12px calc(16px + env(safe-area-inset-bottom, 0px)); }
}

/* 小屏手机 */
@media (max-width: 420px) {
  .navbar .brand span { font-size: 1rem; }
  .resource { padding: 3px 6px; font-size: 0.82rem; }
  .resource img { width: 16px; height: 16px; }
  .btn { padding: 8px 10px; font-size: 0.9rem; }
  .card { padding: 10px; }
  .shop-grid, .friends-grid { grid-template-columns: 1fr; }
  .hero-text h1 { font-size: 1.45rem; }
  .tabs { flex-wrap: wrap; }
  .tab { flex: 1 1 30%; }
}

/* 移动端浏览器对 background-attachment: fixed 支持差（会抖动/错位），改为随页面滚动 */
@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  html, body {
    background-attachment: scroll, scroll;
    background-size: 100% 100%, 360px 203px;
  }
}

/* 尊重系统「减少动态效果」设置：只保留必要的位移，不做多余动画 */
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .oxide-bar { transition: none; }
}

/* 邮箱验证横幅 */
.verify-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: rgba(193,62,62,0.22);
  border: 2px solid var(--mc-red);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.95rem; line-height: 1.6;
}
