/* =========================
   基础设置
========================= */

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

html {
  background-color: var(--page-bg);
}

body {
  min-height: 100vh;
  overflow-x: hidden;

  color: var(--text);

  font-family:
    "Yu Mincho",
    "Hiragino Mincho ProN",
    "Noto Serif JP",
    "MS Mincho",
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    serif;
}

a,
button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}


/* =========================
   页面背景
========================= */

.unit2-page {
  position: relative;
  isolation: isolate;

  width: 100%;
  min-height: 100vh;

  padding:
    clamp(28px, 4.5vh, 54px)
    clamp(28px, 7vw, 108px)
    clamp(38px, 6vh, 70px);

  overflow-x: hidden;

  background-color: var(--page-bg);
}


/* 背景层次层 */

.unit2-page::before {
  content: "";

  position: absolute;
  inset: 0;

  z-index: 0;
  pointer-events: none;

  background:
    linear-gradient(
      90deg,
      var(--border) 0%,
      transparent 48%,
      var(--border) 100%
    ),
    linear-gradient(
      180deg,
      transparent 0%,
      var(--border) 100%
    );
}

.page-header,
.unit-introduction,
.category-menu,
.unit-detail,
.page-footer {
  position: relative;
  z-index: 2;
}


/* =========================
   页面顶部
========================= */

.page-header {
  display: grid;

  grid-template-columns:
    clamp(112px, 12vw, 160px)
    1fr;

  align-items: start;

  width: min(100%, 1160px);
  margin: 0 auto clamp(50px, 7vh, 86px);
}


/* 返回按钮 */

.back-link {
  justify-self: start;

  padding-top: 9px;

  color: var(--text);
  text-decoration: none;

  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    sans-serif;

  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.18em;

  text-shadow:
    0 2px 10px rgba(255, 255, 255, 0.48);

  transition:
    color 0.3s ease,
    transform 0.3s ease;
}

.back-link:hover {
  color: var(--text-strong);
  transform: translateX(-5px);
}


/* 考试入口 */

.test-link {
  position: absolute;
  top: 8px;
  right: 0;

  display: flex;
  align-items: baseline;
  gap: 11px;

  padding: 0 1px 8px;

  border-bottom:
    1px solid var(--border);

  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;

  text-shadow:
    0 2px 10px rgba(255, 255, 255, 0.48);

  transition:
    color 0.3s ease,
    border-color 0.3s ease,
    transform 0.3s ease;
}

.test-link-english {
  font-family:
    "Trebuchet MS",
    Arial,
    sans-serif;

  font-size: 0.61rem;
  font-weight: 600;
  letter-spacing: 0.24em;
}

.test-link-japanese {
  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    sans-serif;

  font-size: 0.77rem;
  font-weight: 600;
  letter-spacing: 0.17em;
}

.test-link:hover {
  color: var(--text);

  border-color: var(--text-muted);

  transform: translateX(4px);
}

.test-link:focus-visible {
  outline:
    2px solid var(--border-strong);

  outline-offset: 4px;
}


/* 页面标题 */

.page-heading {
  justify-self: start;
}

.site-name {
  margin: 0 0 14px;

  color: var(--text-muted);

  font-size: 0.67rem;
  letter-spacing: 0.34em;
}

.unit-number {
  margin: 0 0 16px;

  color: var(--text-muted);

  font-family:
    "Trebuchet MS",
    Arial,
    sans-serif;

  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.3em;
}

.page-heading h1 {
  margin: 0;

  color: var(--text);

  font-size: clamp(3.8rem, 7vw, 6.8rem);
  font-weight: 400;
  line-height: 1;

  letter-spacing: 0.11em;

  text-shadow:
    0 3px 16px rgba(255, 255, 255, 0.5),
    0 9px 30px var(--border);
}

.page-reading {
  margin: 22px 0 0;

  color: var(--text-muted);

  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    sans-serif;

  font-size: 0.75rem;
  letter-spacing: 0.2em;
}

.page-description {
  margin: 8px 0 0;

  color: var(--text-muted);

  font-family:
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;

  font-size: 0.7rem;
  letter-spacing: 0.18em;
}


/* =========================
   初始说明
========================= */

.unit-introduction {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;

  width: min(100%, 980px);
  margin: 0 auto 30px;
  padding-bottom: 25px;

  border-bottom:
    1px solid var(--border);
}

.introduction-japanese {
  margin: 0;

  color: var(--text);

  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.introduction-chinese {
  margin: 8px 0 0;

  color: var(--text-muted);

  font-family:
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;

  font-size: 0.7rem;
  letter-spacing: 0.17em;
}

.introduction-decoration {
  display: flex;
  align-items: baseline;
  gap: clamp(15px, 2.5vw, 35px);

  color: rgba(0, 0, 0, 0.12);

  font-size: clamp(2.5rem, 5vw, 5rem);
  line-height: 1;

  user-select: none;
}

.introduction-decoration span:nth-child(2) {
  transform: translateY(-8px);
}

.introduction-decoration span:nth-child(3) {
  transform: translateY(5px);
}

.introduction-decoration span:nth-child(4) {
  font-size: 0.72em;
}


/* =========================
   分类目录
========================= */

.category-menu {
  width: min(100%, 980px);
  margin: 0 auto;

  border-top:
    1px solid var(--border);
}

.category-item {
  display: grid;

  grid-template-columns:
    62px
    minmax(0, 1fr)
    clamp(62px, 8vw, 98px)
    30px;

  align-items: center;
  gap: 20px;

  min-height: clamp(98px, 11vh, 122px);

  border-bottom:
    1px solid var(--border);

  color: var(--text);
  text-decoration: none;

  transition:
    padding-left 0.35s ease,
    background-color 0.35s ease;
}

.category-item:hover {
  padding-left: 14px;

  background-color:
    rgba(255, 255, 255, 0.6);
}


/* 分类编号 */

.category-number {
  color: var(--text-muted);

  font-family:
    "Trebuchet MS",
    Arial,
    sans-serif;

  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}


/* 分类文字 */

.category-text {
  display: grid;

  grid-template-columns:
    minmax(150px, 0.8fr)
    minmax(150px, 1fr)
    minmax(90px, 0.55fr);

  align-items: center;
  gap: 18px;
}

.category-title {
  color: var(--text);

  font-size: clamp(1.8rem, 3vw, 2.8rem);
  font-weight: 400;
  letter-spacing: 0.11em;
}

.category-reading {
  color: var(--text-muted);

  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    sans-serif;

  font-size: 0.76rem;
  letter-spacing: 0.14em;
}

.category-translation {
  color: var(--text-muted);

  font-family:
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;

  font-size: 0.68rem;
  letter-spacing: 0.14em;
}


/* 装饰字 */

.category-example {
  justify-self: center;

  color: var(--text-faint);

  font-size: clamp(3rem, 5vw, 4.8rem);
  font-weight: 400;
  line-height: 1;

  transition:
    color 0.3s ease,
    transform 0.3s ease;
}

.category-item:hover .category-example {
  color: var(--text-muted);
  transform: translateY(-4px);
}


/* 箭头 */

.category-arrow {
  justify-self: end;

  color: var(--text-muted);

  font-family:
    Arial,
    sans-serif;

  font-size: 1.1rem;

  transition:
    color 0.3s ease,
    transform 0.3s ease;
}

.category-item:hover .category-arrow {
  color: var(--text);
  transform: translateX(5px);
}


/* =========================
   分类详情
========================= */

.unit-detail {
  width: min(100%, 1160px);
  margin: 0 auto;

  animation:
    detailFadeIn 0.45s ease both;
}

.detail-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;

  margin-bottom: 44px;
  padding-bottom: 30px;

  border-bottom:
    1px solid var(--border);
}

.detail-label {
  margin: 0 0 13px;

  color: var(--text-muted);

  font-family:
    "Trebuchet MS",
    Arial,
    sans-serif;

  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.3em;
}

.detail-title {
  margin: 0;

  color: var(--text);

  font-size: clamp(3.5rem, 7vw, 6.4rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.12em;
}

.detail-reading {
  margin: 19px 0 0;

  color: var(--text-muted);

  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    sans-serif;

  font-size: 0.76rem;
  letter-spacing: 0.17em;
}

.detail-translation {
  margin: 8px 0 0;

  color: var(--text-muted);

  font-family:
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;

  font-size: 0.7rem;
  letter-spacing: 0.15em;
}


/* 返回分类 */

.return-button {
  padding: 12px 2px;

  background: transparent;

  color: var(--text-muted);

  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    sans-serif;

  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;

  border-bottom:
    1px solid var(--border-strong);

  cursor: pointer;

  transition:
    color 0.3s ease,
    border-color 0.3s ease,
    transform 0.3s ease;
}

.return-button:hover {
  color: var(--text-strong);

  border-color: var(--text);

  transform: translateY(-3px);
}


/* =========================
   自我测试控制区
========================= */

.study-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 36px;

  margin: 0 0 clamp(48px, 7vh, 72px);
  padding: 24px 0;

  border-top:
    1px solid var(--border);

  border-bottom:
    1px solid var(--border);
}

.control-introduction {
  flex: 0 1 310px;
}

.control-title {
  margin: 0;

  color: var(--text);

  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.15em;
}

.control-description {
  margin: 9px 0 0;

  color: var(--text-muted);

  font-family:
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;

  font-size: 0.68rem;
  letter-spacing: 0.08em;
  line-height: 1.7;
}

.control-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.control-button {
  min-height: 38px;
  padding: 8px 14px;

  border:
    1px solid var(--border);

  background:
    rgba(255, 255, 255, 0.5);

  color: var(--text-muted);

  font-family:
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;

  font-size: 0.67rem;
  font-weight: 500;
  letter-spacing: 0.09em;

  cursor: pointer;

  transition:
    color 0.25s ease,
    background-color 0.25s ease,
    border-color 0.25s ease,
    transform 0.25s ease;
}

.control-button:hover {
  color: var(--text);

  border-color: var(--text-muted);

  background:
    rgba(255, 255, 255, 0.8);

  transform: translateY(-2px);
}

.control-button.is-active {
  color: var(--text);

  border-color: var(--text-muted);

  background:
    rgba(255, 255, 255, 0.75);
}

.control-button:focus-visible {
  outline:
    2px solid var(--border-strong);

  outline-offset: 3px;
}


/* =========================
   单词分组
========================= */

.word-group {
  margin-bottom: clamp(52px, 7vh, 80px);

  content-visibility: auto;
  contain-intrinsic-size: 500px;
}

.group-header {
  margin-bottom: 21px;
}

.group-number {
  margin: 0 0 10px;

  color: var(--text-muted);

  font-family:
    "Trebuchet MS",
    Arial,
    sans-serif;

  font-size: 0.63rem;
  letter-spacing: 0.25em;
}

.group-title {
  margin: 0;

  color: var(--text);

  font-size: clamp(1.55rem, 3vw, 2.45rem);
  font-weight: 400;
  letter-spacing: 0.1em;
}

.group-description {
  margin: 10px 0 0;

  color: var(--text-muted);

  font-family:
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;

  font-size: 0.68rem;
  letter-spacing: 0.12em;
  line-height: 1.8;
}


/* 单词区域 */

.word-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));

  column-gap: clamp(30px, 6vw, 90px);

  border-top:
    1px solid var(--border);
}

.word-item {
  display: grid;

  grid-template-columns:
    minmax(92px, 0.85fr)
    minmax(122px, 1.1fr)
    minmax(76px, 0.7fr);

  align-items: center;
  gap: 15px;

  min-height: 78px;
  padding: 13px 8px;

  border-bottom:
    1px solid var(--border);

  transition:
    background-color 0.3s ease,
    padding-left 0.3s ease;
}

.word-item:hover {
  padding-left: 15px;

  background-color:
    rgba(255, 255, 255, 0.6);
}


/* =========================
   单词三列独立盖板
========================= */

.word-part {
  position: relative;

  display: flex;
  align-items: center;

  width: 100%;
  min-width: 0;
  min-height: 54px;

  margin: 0;
  padding: 0;

  overflow: hidden;

  border: 0;
  background: transparent;

  color: inherit;
  text-align: left;

  cursor: pointer;

  font: inherit;

  -webkit-tap-highlight-color:
    transparent;
}


/*
  保证盖板出现和消失时，
  原文字位置不会发生变化。
*/

.word-part > .word-term,
.word-part > .word-reading,
.word-part > .word-meaning {
  width: 100%;

  transition:
    opacity 0.24s ease;
}


/*
  遮挡时隐藏真实文字。
*/

.word-part.is-covered > .word-term,
.word-part.is-covered > .word-reading,
.word-part.is-covered > .word-meaning {
  opacity: 0;
}


/* 盖板 */

.cover-layer {
  position: absolute;
  inset: 6px 0;

  display: flex;
  align-items: center;
  justify-content: center;

  color: transparent;

  background:
    rgba(255, 255, 255, 0.65);

  box-shadow: none;
  border: none;

  font-size: 0;
  line-height: 0;

  opacity: 0;
  pointer-events: none;

  transform: translateY(2px);

  transition:
    opacity 0.24s ease,
    transform 0.24s ease,
    background-color 0.24s ease;
}


/* 盖板前方的小短线 */

.cover-layer::before {
  content: "";

  display: block;

  width: 26px;
  height: 1px;

  background:
    var(--border);
}


/* 遮挡状态下显示盖板 */

.word-part.is-covered .cover-layer {
  opacity: 1;
  pointer-events: auto;

  transform: translateY(0);
}


/* 悬停时稍微增强提示 */

.word-part.is-covered:hover .cover-layer {
  background:
    rgba(255, 255, 255, 0.7);
}


/* 键盘操作焦点 */

.word-part:focus-visible {
  outline:
    2px solid var(--border-strong);

  outline-offset: 3px;
}

.word-term {
  color: var(--text);

  font-size: clamp(1.3rem, 2.2vw, 2rem);
  font-weight: 400;
  letter-spacing: 0.08em;
}

.word-reading {
  color: var(--text);

  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    sans-serif;

  font-size: clamp(0.88rem, 1.15vw, 1.05rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.65;

  text-shadow:
    0 1px 5px rgba(255, 255, 255, 0.42);
}

.word-meaning {
  color: var(--text);

  font-family:
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;

  font-size: clamp(0.82rem, 1.05vw, 0.98rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.65;

  text-shadow:
    0 1px 5px rgba(255, 255, 255, 0.38);
}


/* =========================
   学习提示
========================= */

.study-notes {
  margin-top: 20px;
  padding: 28px 0;

  border-top:
    1px solid var(--border);

  border-bottom:
    1px solid var(--border);
}

.notes-title {
  margin: 0 0 18px;

  color: var(--text);

  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: 0.15em;
}

.notes-list {
  display: grid;
  gap: 12px;

  margin: 0;
  padding: 0;

  list-style: none;
}

.notes-list li {
  position: relative;

  padding-left: 20px;

  color: var(--text-muted);

  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    "KaiTi",
    "STKaiti",
    "Microsoft YaHei",
    sans-serif;

  font-size: 0.73rem;
  letter-spacing: 0.08em;
  line-height: 1.9;
}

.notes-list li::before {
  content: "—";

  position: absolute;
  left: 0;

  color: var(--text-faint);
}


/* =========================
   页面底部
========================= */

.page-footer {
  width: min(100%, 1160px);
  margin: clamp(62px, 9vh, 100px) auto 0;
}

.page-footer p {
  margin: 0;

  color: var(--text-muted);

  font-size: 0.68rem;
  letter-spacing: 0.2em;
}


/* =========================
   动画
========================= */

@keyframes detailFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* =========================
   中等尺寸屏幕
========================= */

@media (max-width: 1000px) {

  .category-text {
    grid-template-columns:
      minmax(130px, 0.8fr)
      minmax(130px, 1fr);
  }

  .category-translation {
    display: none;
  }

  .word-grid {
    column-gap: 38px;
  }

  .word-item {
    grid-template-columns:
      minmax(82px, 0.85fr)
      minmax(110px, 1.1fr)
      minmax(68px, 0.7fr);
  }

}


/* =========================
   平板
========================= */

@media (max-width: 800px) {

  .page-header {
    grid-template-columns:
      100px
      1fr;
  }

  .introduction-decoration {
    display: none;
  }

  .category-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    gap: 7px;
  }

  .category-translation {
    display: block;
  }

  .word-grid {
    grid-template-columns: 1fr;
  }

}


/* =========================
   手机
========================= */

@media screen and (max-width: 600px) {

  .unit2-page {
    padding: 23px 7vw 48px;
    background-position: 36% top;
  }


  /* 页面顶部 */

  .page-header {
    display: block;

    width: 100%;
    margin-bottom: 48px;
  }

  .back-link {
    display: inline-block;
    margin-bottom: 31px;
  }


  /* 手机端考试入口 */

  .test-link {
    top: 8px;
    right: 0;

    gap: 7px;
    padding-bottom: 7px;
  }

  .test-link-english {
    font-size: 0.56rem;
  }

  .test-link-japanese {
    font-size: 0.72rem;
  }


  /* 页面标题 */

  .page-heading {
    padding-left: 2vw;
  }

  .page-heading h1 {
    font-size: clamp(3.2rem, 15vw, 5rem);
    letter-spacing: 0.07em;
  }


  /* 分类说明 */

  .unit-introduction {
    display: block;
    margin-bottom: 22px;
  }


  /* 分类目录 */

  .category-item {
    grid-template-columns:
      39px
      minmax(0, 1fr)
      50px
      20px;

    min-height: 102px;
    gap: 10px;
  }

  .category-item:hover {
    padding-left: 8px;
  }

  .category-title {
    font-size: clamp(1.45rem, 7vw, 2rem);
  }

  .category-reading {
    font-size: 0.65rem;
  }

  .category-translation {
    font-size: 0.61rem;
  }

  .category-example {
    font-size: clamp(2.8rem, 13vw, 4rem);
  }


  /* 详情标题 */

  .detail-header {
    display: block;
  }

  .detail-title {
    font-size: clamp(3.2rem, 15vw, 4.8rem);
  }

  .return-button {
    margin-top: 28px;
  }


  /* 自我测试控制区 */

  .study-controls {
    display: block;

    margin-bottom: 44px;
    padding: 21px 0;
  }

  .control-actions {
    justify-content: flex-start;

    margin-top: 18px;
  }

  .control-button {
    flex:
      1 1 calc(50% - 9px);

    min-height: 42px;

    text-align: center;
  }


  /* 单词 */

  .word-item {
    grid-template-columns:
      minmax(88px, 0.88fr)
      minmax(118px, 1.12fr);

    gap: 8px 14px;

    min-height: 92px;
  }


  /*
    现在网格中的直接子元素是三个按钮，
    因此要把位置设置在按钮上。
  */

  .word-part-term {
    grid-row: 1 / 3;
  }

  .word-part-meaning {
    grid-column: 2;
  }


  /* 日语写法 */

  .word-term {
    font-size:
      clamp(1.25rem, 6vw, 1.7rem);
  }


  /* 假名读音 */

  .word-reading {
    font-size: 0.84rem;
    line-height: 1.6;
  }


  /* 中文释义 */

  .word-meaning {
    font-size: 0.78rem;
    line-height: 1.6;
  }


  /* 手机盖板点击范围 */

  .word-part {
    min-height: 42px;
  }

  .word-part-term {
    min-height: 84px;
  }

  .cover-layer {
    inset: 2px 0;

    font-size: 0.58rem;
    letter-spacing: 0.08em;
  }

}


/* =========================
   减少动态效果
========================= */

@media (prefers-reduced-motion: reduce) {

  .unit-detail {
    animation: none;
  }

  .back-link,
  .test-link,
  .category-item,
  .category-example,
  .category-arrow,
  .return-button,
  .word-item,
  .word-part,
  .control-button {
    transition: none;
  }

}