/* Ported from Word Atlas (word-atlas @9eff300, src/styles/app.css). MIT License. Copyright (c) 2026 Word Atlas contributors. */
/* Full MIT text: site/vendor/word-atlas/LICENSE. Round 1c sections copied verbatim: toasts, atlas, practice, me, word galaxy (+ mini galaxy). Renamed .tile -> .atile (our spell letter tiles already use .tile). */
/* Our layout overrides live in app.css. */

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: calc(var(--tab) + 20px);
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast 0.35s var(--spring);
}
.toast-warn {
  background: var(--terra);
  color: #fff;
}
@keyframes toast {
  from {
    transform: translateY(16px) scale(0.96);
    opacity: 0;
  }
}

/* ---------- atlas ---------- */

.atlas-head {
  display: grid;
  gap: 22px;
  align-items: end;
  margin-bottom: 22px;
}
.atlas-head .eyebrow {
  margin-bottom: 12px;
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 8px 0 18px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-3);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search:focus-within {
  border-color: var(--ink-3);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--terra) 14%, transparent);
}
.search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: none;
  font-size: 16px;
  color: var(--ink);
  min-width: 0;
}
@media (min-width: 900px) {
  .atlas-head {
    grid-template-columns: 1fr 380px;
  }
}
.filters {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
  position: relative;
  z-index: 2;
}
.filters-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.result-count {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.vgrid,
.vlist {
  position: relative;
}
.atile {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 7px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  will-change: transform;
  transition: box-shadow 0.35s var(--ease), border-color 0.3s;
}
.atile:hover {
  border-color: var(--line-strong);
  box-shadow: 0 22px 40px -24px rgba(30, 38, 64, 0.45);
}
.atile .illo {
  border-radius: 16px;
  flex: none;
}
.atile .illo img {
  transition: opacity 0.5s var(--ease), transform 0.9s var(--ease);
}
.atile:hover .illo img {
  transform: scale(1.045);
}
.atile-no {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 2;
  padding: 3px 7px;
  border-radius: 6px;
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.04em;
  color: var(--ink-2);
  background: color-mix(in oklab, #fbf8f2 88%, transparent);
  backdrop-filter: blur(4px);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.25s, transform 0.3s var(--ease);
}
.atile:hover .atile-no,
.atile:focus-visible .atile-no {
  opacity: 1;
  transform: none;
}
.atile-text {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 8px;
  padding: 10px 6px 2px;
  min-width: 0;
}
.atile-word {
  font: 600 18px/1.2 var(--serif);
  font-variation-settings: "opsz" 24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.atile-zh {
  grid-column: 1 / -1;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.atile-lv {
  font: 700 10px var(--mono);
  color: var(--lv);
  background: var(--lv-soft);
  padding: 3px 6px;
  border-radius: 6px;
}
.atile.is-learning .illo::before,
.atile.is-mastered .illo::before {
  content: "";
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 2;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ochre);
  box-shadow: 0 0 0 2.5px #fbf8f2;
}
.atile.is-mastered .illo::before {
  background: var(--sage);
}
@media (max-width: 559px) {
  .atile {
    padding: 5px;
    border-radius: 18px;
  }
  .atile .illo {
    border-radius: 13px;
  }
  .atile-word {
    font-size: 16px;
  }
  .atile-text {
    padding: 8px 4px 0;
  }
  .atile-no {
    display: none;
  }
}
.row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: grid;
  grid-template-columns: 48px minmax(90px, 200px) minmax(0, 160px) 1fr 12px 36px;
  align-items: center;
  gap: 14px;
  padding: 6px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background-color 0.15s;
}
.row:hover {
  background: var(--card);
}
.row-art {
  width: 48px;
  border-radius: 10px;
}
.row-word {
  font: 600 18px var(--serif);
  font-variation-settings: "opsz" 24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-ipa {
  color: var(--ink-3);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-zh {
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.row-dot.is-learning {
  background: var(--ochre);
}
.row-dot.is-mastered {
  background: var(--sage);
}
@media (max-width: 640px) {
  .row {
    grid-template-columns: 44px 1fr 10px 34px;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 0;
  }
  .row-art {
    grid-row: 1 / 3;
    width: 44px;
  }
  .row-ipa {
    display: none;
  }
  .row-word {
    grid-column: 2;
    font-size: 17px;
  }
  .row-zh {
    grid-column: 2;
    grid-row: 2;
    font-size: 12.5px;
  }
  .row-dot {
    grid-column: 3;
    grid-row: 1 / 3;
  }
  .row .speak {
    grid-column: 4;
    grid-row: 1 / 3;
  }
}
.empty {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 48px 0;
  color: var(--ink-3);
  text-align: center;
}
.empty img {
  width: 180px;
  border-radius: 24px;
}

/* ---------- practice ---------- */

.practice-grid {
  display: grid;
  gap: 16px;
}
.practice-grid .panel > .eyebrow:not(:first-child) {
  margin-top: 24px;
}
.practice-grid .btn-xl {
  width: 100%;
  margin-top: 18px;
}
.practice-grid .muted {
  margin-top: 10px;
}
@media (min-width: 900px) {
  .practice-grid {
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
  }
}
.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.mode-card {
  display: grid;
  gap: 6px;
  justify-items: start;
  text-align: left;
  padding: 16px;
  border-radius: 18px;
  border: 1.5px solid var(--line-strong);
  background: var(--card-2);
  transition: all 0.25s var(--ease);
}
.mode-card svg {
  color: var(--ink-3);
}
.mode-card b {
  font: 600 18px var(--serif);
}
.mode-card small {
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.45;
}
.mode-card:hover {
  border-color: var(--ink-4);
}
.mode-card.is-on {
  border-color: var(--ink);
  background: var(--card);
  box-shadow: var(--shadow);
}
.mode-card.is-on svg {
  color: var(--terra);
}
@media (max-width: 520px) {
  .mode-card small {
    display: none;
  }
}
.practice-side img {
  width: 100%;
  max-width: 280px;
  margin: 0 auto 18px;
  border-radius: 24px;
}
.typing-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.typing-meter {
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.typing-meter b {
  color: var(--ink);
  font: 600 18px var(--serif);
}
.typing-stage {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 22px;
  justify-items: center;
  text-align: center;
  cursor: text;
}
.typing-cue {
  display: grid;
  justify-items: center;
  gap: 14px;
}
.typing-cue .illo {
  width: 200px;
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.typing-cue p {
  font-size: 18px;
  font-weight: 600;
}
.typing-zh {
  color: var(--ink-2);
  font-size: 16px;
  display: grid;
  gap: 10px;
  justify-items: center;
}
.typing-text {
  font: 400 clamp(22px, 3.6vw, 32px) / 1.6 var(--mono);
  letter-spacing: 0.01em;
  color: var(--ink-4);
  text-align: left;
  word-break: break-word;
}
.typing-text.is-word {
  font: 600 clamp(40px, 8vw, 64px) / 1.2 var(--serif);
  letter-spacing: 0.02em;
}
.typing-text span {
  border-radius: 3px;
  transition: color 0.1s;
}
.typing-text .is-ok {
  color: var(--ink);
}
.typing-text .is-bad {
  color: var(--terra);
  background: var(--terra-soft);
}
.typing-text .is-caret {
  box-shadow: -2px 0 0 var(--terra);
  animation: caret 1s steps(1) infinite;
}
@keyframes caret {
  50% {
    box-shadow: -2px 0 0 transparent;
  }
}
.typing-input {
  position: absolute;
  opacity: 0;
  inset: 0;
  font-size: 16px;
}
.typing-help {
  font-size: 13px;
}
.typing-done {
  max-width: 560px;
  margin: 40px auto;
  text-align: center;
}

/* ---------- me ---------- */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin: 0 0 20px;
}
.stat-strip > div {
  background: var(--card);
  padding: 18px 20px;
}
.stat-strip > div:last-child {
  grid-column: 1 / -1;
}
.stat-strip dt {
  font-size: 12.5px;
  color: var(--ink-3);
}
.stat-strip dd {
  margin: 4px 0 0;
  font: 600 34px/1 var(--serif);
  font-variation-settings: "opsz" 72;
  font-variant-numeric: tabular-nums;
}
.stat-strip dd small {
  font: 500 12px var(--sans);
  color: var(--ink-3);
  margin-left: 4px;
}
@media (min-width: 760px) {
  .stat-strip {
    grid-template-columns: repeat(5, 1fr);
  }
  .stat-strip > div:last-child {
    grid-column: auto;
  }
}
.me-grid {
  display: grid;
  gap: 16px;
}
@media (min-width: 900px) {
  .me-grid {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  .me-grid .settings {
    grid-row: span 2;
  }
}
.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  margin-bottom: 14px;
}
.heatmap span {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--paper-2);
}
.heatmap .h1 {
  background: color-mix(in oklab, var(--sage) 35%, var(--paper-2));
}
.heatmap .h2 {
  background: color-mix(in oklab, var(--sage) 60%, var(--paper-2));
}
.heatmap .h3 {
  background: var(--sage);
}
.heatmap .h4 {
  background: var(--sage-ink);
}
.heatmap .hx {
  background: transparent;
}
.forecast {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  height: 180px;
}
.forecast li {
  display: grid;
  grid-template-rows: 1fr auto auto;
  justify-items: center;
  gap: 4px;
}
.forecast span {
  align-self: end;
  width: 100%;
  max-width: 34px;
  min-height: 4px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--sky), color-mix(in oklab, var(--sky) 60%, var(--paper-2)));
}
.forecast b {
  font: 600 15px var(--serif);
  font-variant-numeric: tabular-nums;
}
.forecast small {
  font-size: 11px;
  color: var(--ink-3);
}
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.settings .eyebrow + .field {
  border-top: 0;
  padding-top: 0;
}
.field > div:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.field b {
  font-weight: 600;
  font-size: 15px;
}
.field small {
  color: var(--ink-3);
  font-size: 12.5px;
}
.toggle {
  cursor: pointer;
  position: relative;
  flex-wrap: nowrap;
}
.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch {
  flex: none;
  width: 48px;
  height: 28px;
  border-radius: 28px;
  background: var(--paper-3);
  position: relative;
  transition: background-color 0.25s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s var(--spring);
}
.toggle input:checked + .switch {
  background: var(--sage);
}
.toggle input:checked + .switch::after {
  transform: translateX(20px);
}
.toggle input:focus-visible + .switch {
  outline: 2px solid var(--terra);
  outline-offset: 3px;
}
.data-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ---------- word galaxy ---------- */

.galaxy {
  position: relative;
  overflow: hidden;
  background: #090c18;
  isolation: isolate;
}
.galaxy canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}
.galaxy-full {
  height: min(78vh, 820px);
  min-height: 460px;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  color: #f3ecdf;
  margin: 0 calc(-1 * min(var(--gutter), 12px));
}
.galaxy-full canvas {
  cursor: grab;
}
.galaxy-full canvas:active {
  cursor: grabbing;
}
@media (max-width: 759px) {
  .galaxy-full {
    height: calc(100dvh - var(--top) - var(--tab) - 150px);
    min-height: 420px;
    border-radius: 24px;
    margin: 0 calc(-1 * var(--gutter) + 6px);
  }
}
.galaxy-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.galaxy-labels span {
  position: absolute;
  left: 0;
  top: 0;
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.24em;
  color: var(--c);
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s;
  will-change: transform;
}
.galaxy-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  border-radius: 18px;
  background: rgba(20, 25, 44, 0.78);
  border: 1px solid rgba(243, 236, 223, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.8);
  color: #f3ecdf;
  text-align: left;
  animation: sheet-pop 0.2s var(--ease);
  max-width: 260px;
}
.galaxy-tip .illo {
  width: 56px;
  flex: none;
  border-radius: 12px;
}
.galaxy-tip span {
  display: grid;
  min-width: 0;
}
.galaxy-tip b {
  font: 600 19px var(--serif);
  font-variation-settings: "opsz" 30;
}
.galaxy-tip small {
  font-size: 12.5px;
  color: rgba(243, 236, 223, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.galaxy-hud {
  position: absolute;
  left: 22px;
  top: 20px;
  pointer-events: none;
}
.galaxy-hud p {
  font-size: 13px;
  color: rgba(243, 236, 223, 0.7);
}
.galaxy-hud b {
  font: 600 30px var(--serif);
  color: #ffe2a8;
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
}
.galaxy-legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: rgba(243, 236, 223, 0.6);
}
.galaxy-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}
.galaxy-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.lg-dust {
  background: #8a90b0;
  opacity: 0.6;
}
.lg-learning {
  background: #f2c46d;
  box-shadow: 0 0 8px #f2c46d;
}
.lg-mastered {
  background: #fff6e6;
  box-shadow: 0 0 10px #fff;
}
.galaxy-controls {
  position: absolute;
  right: 14px;
  top: 14px;
  display: grid;
  gap: 6px;
}
.galaxy-controls .icon-btn {
  color: rgba(243, 236, 223, 0.8);
  background: rgba(243, 236, 223, 0.08);
  border: 1px solid rgba(243, 236, 223, 0.1);
}
.galaxy-controls .icon-btn:hover {
  background: rgba(243, 236, 223, 0.18);
  color: #fff;
}
.galaxy-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(243, 236, 223, 0.45);
  pointer-events: none;
}
.galaxy-fallback {
  display: none;
}

/* Mini galaxy on Today and in the summary */
.galaxy-mini {
  position: absolute;
  inset: 0;
}
.galaxy-panel {
  position: relative;
  min-height: 340px;
  border-radius: var(--r-xl);
  overflow: hidden;
  background: #090c18;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  color: #f3ecdf;
  isolation: isolate;
}
.galaxy-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(9, 12, 24, 0.85) 0%, rgba(9, 12, 24, 0.35) 45%, transparent 70%);
  pointer-events: none;
}
.galaxy-panel-copy {
  position: relative;
  z-index: 2;
  max-width: 420px;
  padding: 36px 34px;
  display: grid;
  gap: 10px;
  justify-items: start;
}
.galaxy-panel-copy h3 {
  font: 600 clamp(28px, 4vw, 40px) / 1.1 var(--serif);
  letter-spacing: -0.01em;
}
.galaxy-panel-copy h3 b {
  color: #ffe2a8;
}
.galaxy-panel-copy p {
  color: rgba(243, 236, 223, 0.72);
  font-size: 14.5px;
  max-width: 34ch;
}
.galaxy-panel-copy .btn {
  margin-top: 8px;
}
.galaxy-panel:hover .btn-glass {
  background: rgba(255, 255, 255, 0.24);
}
@media (max-width: 759px) {
  .galaxy-panel {
    min-height: 420px;
  }
  .galaxy-panel::after {
    background: linear-gradient(180deg, rgba(9, 12, 24, 0.85) 0%, rgba(9, 12, 24, 0.2) 55%, transparent 80%);
  }
  .galaxy-panel-copy {
    padding: 26px 22px;
  }
}
.summary-sky {
  position: relative;
  height: 280px;
  margin: 0 auto 22px;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #090c18;
}
.summary-sky p {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  z-index: 2;
  font: 600 18px var(--serif);
  color: #ffe2a8;
  letter-spacing: 0.08em;
  text-shadow: 0 0 20px rgba(255, 210, 140, 0.5);
  animation: page-in 1s 1.2s var(--ease) both;
}
.burst-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 95;
  pointer-events: none;
}
@media (max-width: 759px) {
  .atlas.is-galaxy .atlas-head .lede,
  .atlas.is-galaxy .atlas-head .br-sm {
    display: none;
  }
  .atlas.is-galaxy .atlas-head .display {
    font-size: 26px;
  }
  .atlas.is-galaxy {
    padding-top: 16px;
  }
}

