/* ==================================================================
 * 《机械方志》小程序 H5 预览 —— 基础标签样式
 * ------------------------------------------------------------------
 * 微信小程序的 view / text / image / button / input 等标签在浏览器里
 * 并不存在（或语义不同），这里统一补齐它们的默认盒模型与外观，
 * 使 miniprogram 里的 WXSS 能原样生效。
 * 注意：本文件在小程序自身样式之前加载，可被页面样式覆盖。
 * ================================================================== */

:root {
  /* 手机屏幕可视高度，由运行时按实际布局动态写入；构建时 100vh 会换算成它 */
  --mp-vh: 724px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #EAE8E2;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #1A1918;
}

/* ---------------------------- 屏幕容器 ---------------------------- */

.mp-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: #F4F3EF;
}

.mp-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.mp-body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ---------------------------- 基础标签 ---------------------------- */

view,
scroll-view,
swiper,
swiper-item,
picker,
radio-group,
checkbox-group,
block,
form,
navigator {
  display: block;
}

text {
  display: inline;
}

image {
  display: inline-block;
  width: 320px;
  height: 240px;
  overflow: hidden;
  background-color: #eceef1;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  vertical-align: middle;
}

/* 图片缺失时的占位（后端演示数据可能没有图） */
image.mp-img-empty {
  background-image: linear-gradient(135deg, #DDDAD2 0%, #F0E6D4 45%, #DED2BC 100%);
  position: relative;
}

image.mp-img-empty::after {
  content: attr(data-ph);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b6bcc6;
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

/* ------------------------- 原生控件重置 ------------------------- */

button {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  line-height: inherit;
  text-align: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

input,
textarea {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: inherit;
  line-height: inherit;
  resize: none;
  -webkit-appearance: none;
  appearance: none;
}

input::placeholder,
textarea::placeholder {
  color: #b6bcc6;
}

textarea {
  overflow: auto;
}

label {
  display: block;
}

/* ---------------------------- 滚动视图 ---------------------------- */

scroll-view {
  overflow: hidden;
}

scroll-view[scroll-x] {
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

scroll-view[scroll-y] {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

scroll-view::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ---------------------------- 轮播 ---------------------------- */

swiper {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

swiper::-webkit-scrollbar {
  width: 0;
  height: 0;
}

swiper-item {
  display: block;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  overflow: hidden;
}

/* ---------------------------- 选择器 ---------------------------- */

picker {
  cursor: pointer;
}

radio,
checkbox {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 21px;
  height: 21px;
  border: 1px solid #DDDAD2;
  background: #ffffff;
  vertical-align: middle;
  cursor: pointer;
}

radio {
  border-radius: 50%;
}

radio[checked] {
  border-color: #9A4315;
}

radio[checked]::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 50%;
  background: #9A4315;
}

checkbox {
  border-radius: 4px;
}

checkbox[checked] {
  border-color: #9A4315;
  background: #9A4315;
}

checkbox[checked]::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 46%;
  width: 5px;
  height: 10px;
  margin: -6px 0 0 -2.5px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---------------------------- 其他 ---------------------------- */

[hidden] {
  display: none !important;
}
