/* Theme fragments on the home page: each fragment's tag is a small sample of
   its own chapter (the same colours, type and shapes as that chapter's
   header), with the chapter's one-line question under it. */

@font-face {
  font-family: "Tag Sans";
  src: url("./assets/hero/tag-sans.woff") format("woff");
  font-weight: 900;
  font-display: swap;
}

@font-face {
  font-family: "Tag Serif";
  src: url("./assets/hero/tag-serif.woff") format("woff");
  font-weight: 900;
  font-display: swap;
}

@font-face {
  font-family: "Tag Block";
  src: url("./assets/identity/en-block.woff") format("woff");
  font-weight: 900;
  font-display: swap;
}

.fragment-tag {
  --tag-r: 0deg;
  --tag-sans: "Tag Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --tag-serif: "Tag Serif", "Noto Serif SC", "Songti SC", serif;
  --tag-block: "Tag Block", Impact, "Arial Black", sans-serif;
  --tag-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  position: absolute;
  z-index: 4;
  left: 56%;
  top: 78%;
  display: grid;
  justify-items: start;
  gap: 5px;
  font-size: clamp(10px, 0.78vw, 13px);
  line-height: 1;
  white-space: nowrap;
  text-align: left;
  opacity: 0;
  transform: translate(-28%, 10px) rotate(var(--tag-r)) scale(0.92);
  transform-origin: 20% 50%;
  transition:
    opacity 180ms ease,
    transform 360ms cubic-bezier(0.2, 1.3, 0.4, 1);
  pointer-events: none;
}

.fragment-tag__head {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.fragment-tag__head b,
.fragment-tag__head strong,
.fragment-tag__head em {
  font-style: normal;
  font-weight: 900;
}

.fragment-tag__head strong {
  font-size: 2em;
  letter-spacing: 0.06em;
}

.fragment-tag__head strong i {
  font-style: normal;
}

.fragment-tag__line {
  font-family: var(--tag-sans);
  font-size: 1.2em;
  font-weight: 900;
  letter-spacing: 0.04em;
}

/* 01 身份 — the blue slanted plate with a lime shadow */
.fragment-tag--identity {
  --tag-r: -4deg;
}

.fragment-tag--identity .fragment-tag__head {
  padding: 7px 24px 6px 10px;
  color: #fff;
  background: #1b3fae;
  clip-path: polygon(0 0, 100% 0, calc(100% - 13px) 100%, 0 100%);
  filter: drop-shadow(4px 4px 0 #c3ea4f);
}

.fragment-tag--identity .fragment-tag__head b {
  color: #c3ea4f;
  font-family: var(--tag-block);
  font-size: 1.1em;
}

.fragment-tag--identity .fragment-tag__head strong {
  font-family: var(--tag-sans);
}

.fragment-tag--identity .fragment-tag__head em {
  color: #a9b8ff;
  font-family: var(--tag-block);
  font-size: 1em;
  letter-spacing: 0.14em;
}

.fragment-tag--identity .fragment-tag__line {
  margin-left: 12px;
  padding: 4px 16px 4px 8px;
  color: #0c1d57;
  background: #f4f5fa;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}

/* 02 创造 — a manga panel and a speech bubble */
.fragment-tag--creation {
  --tag-r: 3deg;
}

.fragment-tag--creation .fragment-tag__head {
  padding: 6px 12px 5px;
  color: #141414;
  background: #f2efe7;
  box-shadow:
    inset 0 0 0 2.5px #141414,
    4px 4px 0 #141414;
}

.fragment-tag--creation .fragment-tag__head b {
  font-family: var(--tag-block);
  font-size: 1.1em;
}

.fragment-tag--creation .fragment-tag__head strong {
  font-family: var(--tag-sans);
}

.fragment-tag--creation .fragment-tag__head em {
  font-family: var(--tag-block);
  font-size: 1.15em;
  letter-spacing: 0.02em;
  transform: skewX(-12deg);
}

.fragment-tag--creation .fragment-tag__line {
  position: relative;
  margin: 4px 0 0 22px;
  padding: 6px 12px;
  border: 2px solid #141414;
  border-radius: 999px;
  color: #141414;
  background: #fff;
}

.fragment-tag--creation .fragment-tag__line::before {
  content: "";
  position: absolute;
  left: 12px;
  top: -9px;
  width: 12px;
  height: 10px;
  background: #141414;
  clip-path: polygon(0 0, 100% 100%, 30% 100%);
}

/* 03 探索 — a tarot card's caption between double rules */
.fragment-tag--exploration {
  --tag-r: -2deg;
  justify-items: center;
}

.fragment-tag--exploration .fragment-tag__head {
  padding: 8px 14px 7px;
  color: #0a0b0e;
  background: #fcfcfd;
  box-shadow:
    0 0 0 1px #0a0b0e,
    inset 0 0 0 3px #fcfcfd,
    inset 0 0 0 4px #0a0b0e;
}

.fragment-tag--exploration .fragment-tag__head b,
.fragment-tag--exploration .fragment-tag__head em {
  font-family: var(--tag-mono);
  font-size: 0.9em;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.fragment-tag--exploration .fragment-tag__head strong {
  font-family: var(--tag-serif);
}

.fragment-tag--exploration .fragment-tag__line {
  padding: 4px 10px;
  color: #0a0b0e;
  background: #fcfcfd;
  font-family: var(--tag-serif);
  box-shadow: 0 0 0 1px #0a0b0e;
}

/* 04 灵感 — black, a dot screen thickening to the right, white marks */
.fragment-tag--inspiration {
  --tag-r: 2deg;
}

.fragment-tag--inspiration .fragment-tag__head {
  padding: 8px 34px 7px 10px;
  color: #f2f2ee;
  background:
    linear-gradient(90deg, #040404 0 calc(100% - 42px), rgba(4, 4, 4, 0) 100%),
    radial-gradient(circle, rgba(242, 242, 238, 0.5) 0.9px, transparent 1.35px) 0 0 / 4px 4px,
    #040404;
  box-shadow: 0 0 0 1px rgba(242, 242, 238, 0.6);
}

.fragment-tag--inspiration .fragment-tag__head b,
.fragment-tag--inspiration .fragment-tag__head em {
  color: #8d8d89;
  font-family: var(--tag-mono);
  font-size: 0.9em;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.fragment-tag--inspiration .fragment-tag__head strong {
  font-family: var(--tag-sans);
}

.fragment-tag--inspiration .fragment-tag__line {
  margin-left: 10px;
  padding: 4px 8px;
  color: #f2f2ee;
  background: #040404;
  box-shadow: 0 0 0 1px rgba(242, 242, 238, 0.32);
}

/* 05 未来 — ransom-note letters on a red slash */
.fragment-tag--vision {
  --tag-r: -6deg;
}

.fragment-tag--vision .fragment-tag__head {
  align-items: center;
  gap: 4px;
  padding: 5px 18px 6px 8px;
  background: #e5121e;
  clip-path: polygon(0 8%, 100% 0, calc(100% - 10px) 100%, 6px 92%);
}

.fragment-tag--vision .fragment-tag__head b {
  margin-right: 2px;
  padding: 2px 4px;
  color: #f6f3ee;
  background: #0b0b0c;
  font-family: var(--tag-block);
  font-size: 1em;
}

.fragment-tag--vision .fragment-tag__head strong {
  display: inline-flex;
  gap: 3px;
  letter-spacing: 0;
}

.fragment-tag--vision .fragment-tag__head strong i {
  display: inline-block;
  padding: 2px 4px;
}

.fragment-tag--vision .fragment-tag__head strong i:nth-child(1) {
  color: #f6f3ee;
  background: #0b0b0c;
  font-family: var(--tag-serif);
  transform: rotate(-6deg);
}

.fragment-tag--vision .fragment-tag__head strong i:nth-child(2) {
  color: #0b0b0c;
  background: #f6f3ee;
  font-family: var(--tag-sans);
  font-size: 0.9em;
  transform: rotate(7deg) translateY(2px);
}

.fragment-tag--vision .fragment-tag__head em {
  display: none;
}

.fragment-tag--vision .fragment-tag__line {
  margin-left: 14px;
  padding: 4px 8px;
  color: #f6f3ee;
  background: #0b0b0c;
  box-shadow: 3px 3px 0 #e5121e;
}

/* ---------- when a tag shows ---------- */

/* a computer: the tag comes up under the pointer or the keyboard focus */
.fragment-button:hover .fragment-tag,
.fragment-button:focus-visible .fragment-tag {
  opacity: 1;
  transform: translate(-28%, 0) rotate(var(--tag-r)) scale(1);
}

/* small touch screens without the turning ring: every fragment keeps a
   compact tag (number and name only), since there is no pointer to hover */
@media (max-width: 820px) and (hover: none) {
  .fragment-field:not(.is-carousel) .fragment-button.is-ready .fragment-tag {
    font-size: 8px;
    opacity: 0.94;
    transform: translate(-28%, 0) rotate(var(--tag-r)) scale(1);
  }

  .fragment-field:not(.is-carousel) .fragment-tag__line {
    display: none;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .fragment-tag {
    font-size: 8px;
  }

  .fragment-tag__line {
    display: none;
  }
}

/* phones held upright: only the fragment at the front of the ring shows its tag */
@media (max-aspect-ratio: 4/5) {
  .fragment-field.is-carousel .fragment-tag {
    left: 50%;
    top: 84%;
    font-size: clamp(9px, 2.7vw, 11px);
  }

  .fragment-field.is-carousel .fragment-button .fragment-tag {
    opacity: 0;
    transform: translate(-50%, 10px) rotate(var(--tag-r)) scale(0.92);
  }

  .fragment-field.is-carousel .fragment-button.is-ready.is-front .fragment-tag {
    opacity: 1;
    transform: translate(-50%, 0) rotate(var(--tag-r)) scale(1);
  }

  .fragment-field.is-carousel .fragment-tag--exploration,
  .fragment-field.is-carousel .fragment-tag {
    justify-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fragment-tag {
    transition: opacity 120ms ease;
  }
}
