/* =========================================================================
   QUALITY NOTE — Pronunciation Row Styling
   Added after the full "In your languages" data audit (see app.js header comment).
   The visual treatment below (slightly smaller + italic + letter-spacing on .phonetic)
   makes it immediately obvious to users that Row 2 is a pronunciation guide,
   not a repeat of the word in Row 1. This supports the strict two-row rule
   enforced in the JavaScript data layer.
   No other CSS changes were required.
   ========================================================================= */

:root {
  --ink: #263238;
  --muted: #66727a;
  --paper: #fffaf0;
  --panel: #ffffff;
  --line: #dde6e4;
  --green: #2f9d74;
  --coral: #f06d5e;
  --blue: #3778c2;
  --yellow: #f6c85f;
  --shadow: 0 18px 48px rgba(38, 50, 56, 0.14);
  --font-latin: "Nunito", system-ui, sans-serif;
  --font-zh: "ZCOOL KuaiLe", "Noto Sans SC", system-ui, sans-serif;
  --font-ru: "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-ja: "Mochiy Pop One", "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-latin);
  background:
    radial-gradient(circle at 12% 18%, rgba(246, 200, 95, 0.22), transparent 28%),
    radial-gradient(circle at 90% 12%, rgba(55, 120, 194, 0.14), transparent 24%),
    linear-gradient(135deg, #f6fbf7 0%, var(--paper) 100%);
}

button {
  font: inherit;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.is-hidden {
  display: none !important;
}

.app-shell {
  width: min(820px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
}

.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(221, 230, 228, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intro-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: clamp(22px, 3vw, 34px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  position: relative;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--blue);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(38, 50, 56, 0.12);
}

.brand-mark span {
  position: absolute;
  display: block;
}

.brand-mark span:nth-child(1) {
  inset: 0 auto auto 0;
  width: 38%;
  height: 46%;
  background: var(--blue);
}

.brand-mark span:nth-child(2) {
  top: 0;
  left: 38%;
  width: 34%;
  height: 28%;
  background: var(--yellow);
  clip-path: polygon(0 0, 100% 0, 84% 100%, 0 82%);
}

.brand-mark span:nth-child(3) {
  top: 0;
  right: 0;
  width: 30%;
  height: 56%;
  background: var(--green);
  clip-path: polygon(12% 0, 100% 0, 100% 100%, 0 84%);
}

.brand-mark span:nth-child(4) {
  top: 46%;
  left: 0;
  width: 30%;
  height: 54%;
  background: var(--coral);
  clip-path: polygon(0 0, 100% 14%, 78% 100%, 0 100%);
}

.brand-mark span:nth-child(5) {
  top: 28%;
  left: 30%;
  width: 42%;
  height: 38%;
  background: #8f6ccf;
  clip-path: polygon(10% 0, 100% 8%, 86% 100%, 0 88%);
}

.brand-mark span:nth-child(6) {
  right: 0;
  bottom: 0;
  width: 36%;
  height: 44%;
  background: #ec8a42;
  clip-path: polygon(0 16%, 100% 0, 100% 100%, 12% 100%);
}

.brand-mark span:nth-child(7) {
  left: 30%;
  bottom: 0;
  width: 28%;
  height: 34%;
  background: #55b8a9;
  clip-path: polygon(0 0, 100% 12%, 88% 100%, 0 100%);
}

.brand-mark span:nth-child(8) {
  left: 0;
  top: 35%;
  width: 48%;
  height: 28%;
  background: #f2a7b8;
  clip-path: polygon(0 22%, 86% 0, 100% 78%, 12% 100%);
}

.brand-mark span:nth-child(9) {
  right: 22%;
  bottom: 0;
  width: 24%;
  height: 40%;
  background: #5c8fd6;
  clip-path: polygon(20% 0, 100% 16%, 82% 100%, 0 88%);
}

.brand-mark strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-family: var(--font-latin);
  font-size: 24px;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(38, 50, 56, 0.32);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-latin);
  line-height: 1.02;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3.6vw, 3.5rem);
  white-space: nowrap;
}

.intro-copy {
  max-width: 100%;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.language-box,
.visual-input-section {
  display: grid;
  gap: 14px;
}

.section-heading,
.translations-header,
.result-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-heading h2,
.translations-header h3,
.fact-stack h3 {
  margin: 0;
  font-size: 1.1rem;
}

.section-heading span,
.translations-header span {
  color: var(--muted);
  font-size: 0.9rem;
}

.language-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.language-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.94rem;
  background: #fff;
  cursor: pointer;
}

.language-tile[aria-pressed="true"] {
  border-color: rgba(47, 157, 116, 0.65);
  background: #eaf7f1;
}

.language-name {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  font-weight: 700;
}

.language-font-en,
.language-font-nl {
  font-family: var(--font-latin);
}

.language-font-zh {
  font-family: var(--font-zh);
  font-weight: 400;
}

.language-font-ru {
  font-family: var(--font-ru);
  font-weight: 700;
}

.language-font-ja {
  font-family: var(--font-ja);
  font-weight: 400;
}

.flag-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border-radius: 50%;
}

.check-mark {
  color: var(--green);
  font-size: 0.88rem;
  font-weight: 800;
}

.quick-tries button,
.sound-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.quick-tries {
  display: grid;
  gap: 12px;
  margin-top: 0;
}

.visual-heading {
  margin-top: 0;
}

.emoji-category {
  display: grid;
  gap: 8px;
}

.emoji-category h3 {
  margin: 0;
  font-family: var(--font-latin);
  font-size: 0.9rem;
  font-weight: 800;
}

.emoji-category-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  text-align: left;
  background: #fff;
}

.category-title {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.category-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.category-preview {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--ink);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", system-ui, sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.emoji-category-toggle[aria-expanded="true"] {
  border-color: rgba(47, 157, 116, 0.45);
  color: var(--ink);
  background: #eaf7f1;
}

.emoji-category-toggle[aria-expanded="true"] .category-count {
  color: var(--green);
}

.emoji-category-toggle:hover,
.emoji-category-toggle:focus-visible {
  outline: 3px solid rgba(47, 157, 116, 0.16);
}

.category-chevron {
  color: var(--green);
  font-size: 1.1rem;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 8px;
}

.emoji-grid[hidden] {
  display: none;
}

.emoji-grid button {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 48px;
  padding: 0;
  color: var(--ink);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", system-ui, sans-serif;
  font-size: 1.55rem;
  line-height: 1;
  background: #f5ead0;
}

.emoji-grid button:hover,
.emoji-grid button:focus-visible {
  background: #f8dfad;
  outline: 3px solid rgba(246, 200, 95, 0.35);
}

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(38, 50, 56, 0.36);
}

.result-overlay.is-hidden {
  display: none;
}

.result-dialog {
  position: relative;
  width: min(980px, 100%);
  min-height: min(520px, calc(100vh - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid rgba(221, 230, 228, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.result-overlay.is-expanded {
  padding: 0;
}

.result-overlay.is-expanded .result-dialog {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
}

.result-view {
  display: grid;
  gap: 11px;
  padding: clamp(14px, 1.8vw, 18px);
}

.result-view.is-hidden {
  display: none;
}

.result-topline h2 {
  margin: 2px 0 3px;
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  line-height: 1;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  background: #fff;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  outline: 3px solid rgba(55, 120, 194, 0.16);
}

.hero-word {
  display: grid;
  grid-template-columns: minmax(150px, 0.42fr) minmax(300px, 1fr);
  gap: 12px;
  align-items: stretch;
}

.word-art {
  display: grid;
  place-items: center;
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4fbf8;
  overflow: hidden;
}

.word-art svg {
  width: min(72%, 162px);
  height: auto;
}

.fact-stack {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.fact-stack ul {
  display: grid;
  gap: 5px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.fact-stack li {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 7px;
  color: var(--muted);
  line-height: 1.22;
}

.translation-list {
  display: grid;
  gap: 7px;
}

.translation-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 52px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.translation-word {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.translation-word strong {
  font-family: var(--font-latin);
  font-size: 1.22rem;
}

.translation-word strong.language-font-zh {
  font-family: var(--font-zh);
  font-size: 1.3rem;
  font-weight: 400;
}

.translation-word strong.language-font-ru {
  font-family: var(--font-ru);
  font-size: 1.28rem;
  font-weight: 700;
}

.translation-word strong.language-font-ja {
  font-family: var(--font-ja);
  font-size: 1.14rem;
  font-weight: 400;
}

.translation-word span,
.phonetic {
  color: var(--muted);
}

/* QUALITY NOTE (added after pronunciation data audit)
   The .phonetic row is now guaranteed by the JS data layer to contain real
   pronunciation guidance and never a duplicate of the word above it.
   This small style tweak makes the pronunciation row visually distinct
   at a glance (smaller, slightly spaced, italic) so the two-row rule is
   obvious to users and future developers. No layout or spacing changes. */
.phonetic {
  font-size: 0.92rem;
  font-style: italic;
  letter-spacing: 0.3px;
}

.sound-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #fff;
  font-weight: 800;
  background: var(--blue);
}

.loading-scene {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 22px;
  padding: 28px;
  background: rgba(255, 250, 240, 0.94);
}

.loading-scene.is-hidden {
  display: none;
}

.bubble-word {
  position: relative;
  width: 210px;
  height: 210px;
}

.bubble-word span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  color: white;
  font-family: var(--font-latin);
  font-size: 2rem;
  font-weight: 800;
  animation: float 1.45s ease-in-out infinite;
}

.bubble-word span:nth-child(1) {
  top: 0;
  left: 68px;
  background: var(--green);
}

.bubble-word span:nth-child(2) {
  top: 68px;
  right: 0;
  background: var(--coral);
  animation-delay: 0.12s;
}

.bubble-word span:nth-child(3) {
  bottom: 0;
  left: 68px;
  background: var(--blue);
  animation-delay: 0.24s;
}

.bubble-word span:nth-child(4) {
  top: 68px;
  left: 0;
  background: var(--yellow);
  animation-delay: 0.36s;
}

#loading-text {
  color: var(--muted);
  font-weight: 700;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-12px) scale(1.04);
  }
}

@media (max-width: 860px) {
  .hero-word {
    grid-template-columns: 1fr;
  }

  .app-shell {
    min-height: auto;
    margin: 12px auto;
  }

  .result-dialog {
    width: min(680px, 100%);
  }
}

@media (max-width: 560px) {
  .result-topline {
    align-items: flex-start;
  }

  .result-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
