/* =============================================================================
   The public site: the dictionary's pages, pricing, about and the blog.
   Plain CSS, as these pages don't load the app (site/layout.ts). The colors are
   the app's and the landing page's. Pinyin's tone colors are pastels, so they
   only ever sit on the dark green.
   ============================================================================= */

:root {
  color-scheme: light dark;
  --paper: #eceee6;
  --card: #f6f8f2;
  --line: #c3c9bd;
  --ink: #2d3a2e;
  --soft: #5c6c5c;
  --link: #9a3f06;
  --green: #14301f;
  --cream: #f7ecd9;
  --accent: #f29a32;
  --accent-hover: #f7ab4f;
  --accent-ink: #2a1600;
  --sheet: #fbf6ea;
  --sheet-line: #d9cdb6;
  --sheet-ink: #2b2116;
  --now: #c45a08;
  --chinese: 'LXGW WenKai SC', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --display: 'Bricolage Grotesque', 'Nunito', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1f1a;
    --card: #2a322a;
    --line: #3a453a;
    --ink: #dce5dc;
    --soft: #a3b3a3;
    --link: #f5a84a;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

a { color: var(--link); text-underline-offset: 0.15em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[lang^='zh'] { font-family: var(--chinese); }

h1, h2, h3 { font-family: var(--display); line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; }
h1 { margin: 0; font-size: clamp(2.25rem, 6vw, 3.5rem); font-weight: 800; }
h2 { margin: 0 0 0.75rem; font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 800; }
h3 { margin: 1.5rem 0 0.25rem; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 1rem; text-wrap: pretty; }

main { max-width: 48rem; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2rem) 3rem; }
main:has(.glyphs) { max-width: 72rem; }
main > section, article > section { margin-top: 3rem; }

/* ---- Top bar ---- */
.bar { background: var(--green); color: var(--cream); }
.bar-in { display: flex; align-items: center; gap: 0.75rem; max-width: 72rem; margin: 0 auto; padding: 0.5rem clamp(1rem, 4vw, 2rem); }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; margin-right: auto; color: inherit; font-size: 1.125rem; font-weight: 700; text-decoration: none; }
.bar-links { display: flex; gap: 0.25rem; }
.bar a:not(.brand, .btn) { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 0.75rem; border-radius: 999px; color: inherit; font-weight: 600; text-decoration: none; }
.bar a:not(.brand, .btn):hover { background: rgb(247 236 217 / 0.12); }
.bar a[aria-current='page'] { color: #f5b870; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  min-height: 44px;
  padding: 0.5rem 1.125rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn-lg { min-height: 52px; padding-inline: 1.75rem; }

.bar-menu { position: relative; display: none; }
.bar-menu summary { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; cursor: pointer; list-style: none; }
.bar-menu summary::-webkit-details-marker { display: none; }
.bar-menu nav { position: absolute; z-index: 10; top: calc(100% + 0.5rem); right: 0; display: flex; flex-direction: column; min-width: 11rem; padding: 0.5rem; border-radius: 1rem; background: var(--green); box-shadow: 0 12px 28px rgb(0 0 0 / 0.35); }

@media (max-width: 820px) {
  .bar-links { display: none; }
  .bar-menu { display: block; }
}
@media (max-width: 420px) {
  .bar-in { gap: 0.25rem; }
  .brand { font-size: 1rem; }
}
/* The smallest phones keep the fruit and lose the name, which stays for screen readers. */
@media (max-width: 380px) {
  .brand { font-size: 0; }
}

/* ---- Footer ---- */
.foot { max-width: 48rem; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2rem) 2.5rem; border-top: 1px solid var(--line); color: var(--soft); font-size: 0.875rem; }
.foot a { color: inherit; }
.foot nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.foot-credits { margin-bottom: 1rem; }

/* ---- Pages ---- */
.page-head { margin-top: 1.5rem; }
.lede { margin-top: 1rem; color: var(--soft); font-size: 1.1875rem; }
.cta { margin-top: 3rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; color: var(--soft); font-size: 0.9375rem; }
.crumbs a { color: inherit; }
.crumbs + h1 { margin-top: 1rem; }

.notice { margin: 2rem 0 0; padding: 1rem 1.25rem; border-left: 4px solid var(--accent); border-radius: 0.5rem; background: var(--card); }
.notice:last-child { margin-bottom: 0; }

.prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin: 2rem 0 0; padding: 0; list-style: none; }
.prices li { display: flex; flex-direction: column; padding: 1.5rem; border-radius: 1.25rem; background: var(--green); color: var(--cream); }
.amount { font-family: var(--display); font-size: 2.75rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; color: #f5b870; }
.what { margin-top: 0.75rem; font-weight: 700; }
.note { margin-top: 0.25rem; font-size: 0.9375rem; opacity: 0.85; }

.how { margin: 0; padding-left: 1.5rem; }
.how li { margin-bottom: 0.75rem; padding-left: 0.25rem; }
.ticks { margin: 0; padding-left: 1.25rem; }
.ticks li { margin-bottom: 0.5rem; }

.adds-up { width: 100%; margin-top: 1rem; border-collapse: collapse; }
.adds-up th { color: var(--soft); font-size: 0.875rem; font-weight: 600; text-align: left; }
.adds-up th, .adds-up td { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.adds-up th:last-child, .adds-up td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

main > section.faq h3:first-of-type { margin-top: 0; }


.roles { margin: 0; padding: 0; list-style: none; }
.roles li { margin-bottom: 1rem; padding: 1.25rem; border-radius: 1.25rem; background: var(--card); }
.roles h3 { margin-top: 0; }
.roles p { margin-bottom: 0.5rem; }

.posts { margin: 2rem 0 0; padding: 0; list-style: none; }
.posts li { padding: 1.25rem 0; border-top: 1px solid var(--line); }
.posts time, .post > time { color: var(--soft); font-size: 0.9375rem; }
.posts h2 { margin: 0.25rem 0 0.5rem; }
.posts h2 a { color: inherit; text-decoration: none; }
.posts h2 a:hover { text-decoration: underline; }
.post h1 { margin-top: 1rem; }
.post > time { display: block; margin: 0.75rem 0 2rem; }
.post h2 { margin-top: 2.5rem; }

/* ---- A character's page ---- */
.defs { position: absolute; }

.entry { display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: clamp(1.25rem, 4vw, 2.5rem); margin-top: 1rem; padding: clamp(1rem, 4vw, 2rem); border-radius: 1.5rem; background: var(--green); color: var(--cream); }
.entry a:not(.btn) { color: #f5b870; }
.entry-sheet { position: relative; align-self: start; }
.entry h1 { font-family: var(--chinese); font-size: clamp(3.5rem, 10vw, 5rem); font-weight: 700; line-height: 1; letter-spacing: 0; }
.entry-readings { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0.5rem 0 0; font-size: 1.75rem; font-weight: 700; }
.reading { display: inline-flex; align-items: center; gap: 0.125rem; }
.speak { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--cream); cursor: pointer; }
.speak:hover { background: rgb(247 236 217 / 0.12); }
.entry-gloss { margin: 0.25rem 0 0; font-size: 1.125rem; }
.facts { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; margin: 1.25rem 0 1.5rem; }
.facts dt { font-size: 0.8125rem; opacity: 0.8; }
.facts dd { margin: 0; font-weight: 700; }

.strokes { display: block; width: 100%; border-radius: 0.75rem; background: var(--sheet); }
.grid rect, .grid path { fill: none; stroke: var(--sheet-line); stroke-width: 6; }
.grid path { stroke-dasharray: 22 22; }
.ghost { fill: var(--sheet-line); }
.ink { fill: none; stroke: var(--sheet-ink); stroke-width: 190; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1.1 2; stroke-dashoffset: 1.1; opacity: 0; }
.run .ink { animation: draw 0.55s linear forwards; }
@keyframes draw {
  from { opacity: 1; stroke-dashoffset: 1.1; }
  to { opacity: 1; stroke-dashoffset: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .run .ink { animation: none; opacity: 1; stroke-dashoffset: 0; }
  .replay { display: none; }
}
.replay { position: absolute; right: 0.5rem; bottom: 0.5rem; min-height: 44px; padding: 0 0.875rem; border: 0; border-radius: 999px; background: rgb(43 33 22 / 0.82); color: var(--sheet); font: inherit; font-size: 0.875rem; font-weight: 700; cursor: pointer; }

.steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr)); gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.steps li { position: relative; }
.steps svg { display: block; width: 100%; border-radius: 0.375rem; background: var(--sheet); box-shadow: 0 0 0 1px var(--line); }
.steps .done { fill: var(--sheet-ink); }
.steps .now { fill: var(--now); }
.steps span { position: absolute; top: 0.125rem; left: 0.3125rem; color: #6b5d48; font-size: 0.75rem; font-weight: 700; }

.senses div { display: flex; gap: 1rem; margin-bottom: 0.5rem; }
.senses dt { flex: none; min-width: 3rem; font-weight: 700; }
.senses dd { margin: 0; }
.origin, .parts { color: var(--soft); }
.zh a, .origin a, .parts a, .glyph-row a { color: inherit; text-decoration: none; }
.zh a:hover, .origin a:hover, .parts a:hover, .glyph-row a:hover { color: var(--link); text-decoration: underline; }
.zh b { color: var(--link); font-weight: 700; }

.words { margin: 0; padding: 0; list-style: none; }
.words li { display: grid; grid-template-columns: 6rem 8.5rem minmax(0, 1fr); gap: 0.25rem 1rem; align-items: baseline; padding: 0.625rem 0; border-bottom: 1px solid var(--line); }
.words .zh { font-size: 1.25rem; }
.py { color: var(--soft); font-size: 0.9375rem; }
@media (max-width: 560px) {
  .entry { grid-template-columns: minmax(0, 1fr); }
  .entry-sheet { max-width: 18rem; }
  .words li { grid-template-columns: auto minmax(0, 1fr); }
  .words .def { grid-column: 1 / -1; }
}

.sentences { margin: 0; padding: 0; list-style: none; }
.sentences li { padding: 0.875rem 0; border-bottom: 1px solid var(--line); }
.sentences p { margin: 0; }
.sentences .zh { font-size: 1.25rem; }

.glyph-row { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 1.5rem; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; margin-top: 2rem; }

/* ---- Lists of characters ---- */
.browse { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.75rem; }
.browse a { display: inline-flex; align-items: center; min-height: 36px; padding-inline: 0.75rem; border-radius: 999px; background: var(--card); color: inherit; font-size: 0.875rem; font-weight: 600; text-decoration: none; }
.browse a:hover { color: var(--link); }
.browse a[aria-current='page'] { background: var(--green); color: var(--cream); }
.glyphs { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.5rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.glyphs a { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 0.625rem; align-items: center; height: 100%; padding: 0.5rem 0.75rem; border-radius: 0.75rem; background: var(--card); color: inherit; text-decoration: none; }
.glyphs a:hover { outline: 2px solid var(--accent); }
.glyphs .g { grid-row: span 2; font-size: 2rem; line-height: 1; }
.glyphs .def { overflow: hidden; color: var(--soft); font-size: 0.8125rem; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
