@import url("/brand.css");

:root {
  --ink: #1a2421;
  --ink-soft: #3d4a45;
  --mist: #dfe8e4;
  --paper: #f3f6f4;
  --jade: #1f6f5b;
  --jade-deep: #145243;
  --seal: #b23a2f;
  --line: rgba(26, 36, 33, 0.12);
  --shadow: 0 24px 60px rgba(26, 36, 33, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "DM Sans", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(31, 111, 91, 0.16), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(178, 58, 47, 0.08), transparent 50%),
    linear-gradient(165deg, #eef3f0 0%, #f7f9f7 45%, #e8efe9 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  pointer-events: none;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.25rem, 4vh, 2.5rem);
  padding: clamp(1.5rem, 5vw, 3rem);
  text-align: center;
}

.stage-in-shell {
  min-height: calc(100vh - 0px);
  min-height: calc(100dvh - 0px);
}

.character-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  animation: rise 1s ease-out both;
  user-select: none;
  -webkit-user-select: none;
}

.character-panel .copy-block {
  position: relative;
  display: block;
  width: max-content;
  max-width: 100%;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  isolation: isolate;
}

/* Pinyin/meaning above hanzi in hit-testing — large glyphs overflow their box */
.character-panel .copy-block--pinyin,
.character-panel .copy-block--meaning {
  z-index: 2;
}

.character-panel .copy-block--hanzi {
  z-index: 0;
  /* Clip ink to the layout box so the hit area doesn't cover pinyin/meaning,
     but leave enough height for full CJK glyphs (weight 700 overflows 1em). */
  overflow: hidden;
  line-height: 1.22;
  height: 1.22em;
  font-size: clamp(6.5rem, 22vw, 10rem);
}

.pinyin {
  margin: 0;
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--jade);
  text-transform: lowercase;
  user-select: text;
  -webkit-user-select: text;
}

.hanzi {
  margin: 0;
  padding: 0;
  font-family: "Noto Sans SC", sans-serif;
  font-size: 1em; /* size comes from .copy-block--hanzi */
  font-weight: 700;
  line-height: 1.22;
  height: 1.22em;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.35s ease, opacity 0.35s ease;
  user-select: text;
  -webkit-user-select: text;
}

.hanzi.is-changing {
  opacity: 0;
  transform: translateY(12px) scale(0.96);
}

.meaning {
  margin: 0;
  font-size: 1.05rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  user-select: text;
  -webkit-user-select: text;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  animation: rise 1.05s ease-out 0.18s both;
}

.rate-row {
  display: flex;
  gap: 0.4rem;
}

.rate-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink-soft);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.95rem;
  min-width: 2.6rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.rate-chip:hover {
  border-color: rgba(31, 111, 91, 0.45);
}

.rate-chip.is-active {
  background: var(--jade);
  border-color: var(--jade);
  color: #f7faf8;
}

.speak-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.95rem 1.55rem;
  border-radius: 999px;
  background: var(--jade);
  color: #f7faf8;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow);
  transition: background 0.2s ease, transform 0.2s ease;
}

.speak-btn:hover:not(:disabled) {
  background: var(--jade-deep);
  transform: translateY(-1px);
}

.speak-btn:active:not(:disabled) {
  transform: translateY(0);
}

.speak-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.speak-btn.is-playing {
  background: var(--seal);
}

.speak-icon {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow:
    0 0 0 0 currentColor,
    5px 0 0 -1px currentColor,
    10px 0 0 -2px currentColor;
  animation: pulse-dots 1.4s ease-in-out infinite;
}

.speak-btn:not(.is-playing) .speak-icon {
  animation: none;
  border-radius: 2px;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  box-shadow: none;
  width: 0.75rem;
  height: 0.9rem;
}

.status {
  margin: 0;
  min-height: 1.25rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.status.is-error {
  color: var(--seal);
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  max-width: 28rem;
  animation: rise 1.1s ease-out 0.26s both;
}

.word-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 1.2rem;
  padding: 0.45rem 0.9rem;
  border-radius: 0.55rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.word-chip:hover {
  border-color: rgba(31, 111, 91, 0.45);
}

.word-chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #f4f7f5;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-dots {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .speak-btn {
    width: 100%;
    max-width: 20rem;
    justify-content: center;
  }
}
