:root {
  --nav-h: 64px;
}

html, body {
  margin: 0;
  background: #000;
  color: #bbb;
  font: 16px/1.4 system-ui, sans-serif;
}

main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
}

.page {
  display: block;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

main img, .soon {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: calc((100vh - var(--nav-h)) * var(--ratio));
  max-width: calc((100svh - var(--nav-h) - env(safe-area-inset-bottom)) * var(--ratio));
  height: auto;
}

.soon {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.75em;
  aspect-ratio: var(--ratio);
  box-sizing: border-box;
  border: 1px solid #222;
  color: #888;
  font-size: 1.125rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.soon .num {
  color: #eee;
  font-size: clamp(1.75rem, 8vw, 3rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
}

nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  height: var(--nav-h);
  padding: 0 8px env(safe-area-inset-bottom);
  user-select: none;
}

nav > a, nav > span {
  box-sizing: border-box;
  min-width: 44px;
  padding: 10px 12px;
  border: 1px solid #333;
  border-radius: 10px;
  background: #111;
  color: #eee;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

nav > a:hover, nav > a:focus-visible {
  border-color: #666;
  background: #1c1c1c;
}

nav > a:active {
  background: #262626;
}

nav > span {
  border-color: #1a1a1a;
  background: none;
  color: #3a3a3a;
}

nav > span.count {
  min-width: 4.5em;
  padding: 10px 4px;
  border: none;
  color: #888;
}

.notice {
  justify-content: center;
  align-items: center;
  padding: 0 16px;
  text-align: center;
}

.notice h1 {
  margin: 0 0 0.5em;
  color: #eee;
  font-size: clamp(1.75rem, 8vw, 3rem);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.notice p {
  margin: 0;
  color: #888;
  font-size: 1.125rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.notice a {
  color: #ccc;
}

.soon .missed {
  margin-top: 3em;
  color: #444;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-decoration: none;
}

.soon .missed:hover, .soon .missed:focus-visible {
  color: #888;
}

.explained {
  max-width: 40rem;
  margin: 0 auto;
  padding: 24px 16px 64px;
  color: #ccc;
}

.explained h1, .explained h2 {
  color: #eee;
  font-weight: 600;
}

.explained a {
  color: #ddd;
}

.explained figure {
  margin: 1.5em 0;
}

.explained figure img {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
}

.quality {
  position: relative;
}

.quality summary {
  box-sizing: border-box;
  min-width: 44px;
  padding: 10px 12px;
  border: 1px solid #333;
  border-radius: 10px;
  background: #111;
  color: #888;
  text-align: center;
  list-style: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.quality summary::-webkit-details-marker {
  display: none;
}

.quality[open] summary {
  border-color: #666;
  color: #eee;
}

.quality .menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 15rem;
  padding: 8px;
  border: 1px solid #333;
  border-radius: 12px;
  background: #111;
}

.quality button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 12px;
  border: 1px solid #222;
  border-radius: 8px;
  background: none;
  color: #eee;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.quality button small {
  color: #888;
}

.quality button[aria-pressed="true"] {
  border-color: #888;
  background: #222;
}

.quality .hint {
  margin: 0;
  color: #888;
  font-size: 0.85rem;
}

.quality .hint:empty {
  display: none;
}

iframe.ahead { position: absolute; left: 0; top: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }

nav {
  position: relative;
}

nav a.dev {
  position: absolute;
  bottom: calc(1px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  min-width: 0;
  padding: 0 4px;
  border: none;
  background: none;
  color: #666;
  font-size: 10px;
  line-height: 12px;
}

/* Dev only: the known faults of a page, always in view: under the buttons, or beside the page on a wide screen. */
main:has(+ .faults) {
  min-height: 0;
}

.faults {
  box-sizing: border-box;
  max-width: 40rem;
  margin: 0 auto;
  padding: 4px 16px 32px;
  color: #fc6;
  font-size: 14px;
}

.faults ul {
  margin: 4px 0 0;
  padding-left: 1.2em;
}

@media (min-aspect-ratio: 5/4) {
  .faults {
    position: fixed;
    top: 0;
    right: 0;
    width: calc((100vw - (100vh - var(--nav-h)) * var(--ratio)) / 2);
    max-height: 100vh;
    overflow-y: auto;
    padding-top: 16px;
  }
}

/* The picture books: the picture, the story as real text below it, sized by books.js to fill the space. */

@font-face {
  font-family: "Andika";
  font-display: swap;
  font-weight: 400;
  src: url(/fonts/andika-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Andika";
  font-display: swap;
  font-weight: 400;
  src: url(/fonts/andika-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Nunito";
  font-display: swap;
  font-weight: 700;
  src: url(/fonts/nunito-latin-ext-700-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Nunito";
  font-display: swap;
  font-weight: 700;
  src: url(/fonts/nunito-latin-700-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.kids .page {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.kids .leaf {
  --page-w: max(calc((100svh - var(--nav-h) - env(safe-area-inset-bottom)) * var(--ratio)), min(100vw, 30rem));
  display: flex;
  flex: 1;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  max-width: var(--page-w);
  min-height: calc(min(100vw, var(--page-w)) / (var(--ratio)));
  margin: 0 auto;
  container-type: inline-size;
}

.kids main .leaf img {
  max-width: none;
}

.kids .story {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.kids .text {
  padding: 4.5cqw 8.7cqw 6cqw;
  color: #ece6d8;
  font-family: "Andika", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: calc(4.2cqw * var(--fit, 1));
  line-height: 1.72;
  white-space: pre-line;
}

.kids .text:lang(zh) {
  letter-spacing: 0.04em;
}

.kids .text p, .kids .text h1 {
  margin: 0;
}

.kids .text p + p {
  margin-top: 0.45em;
}

.kids .speech { color: #f4935f; }
.kids .name-y { color: #ecc94b; }
.kids .name-g { color: #74c86e; }
.kids .name-o { color: #f6a04d; }

.kids .ask {
  display: inline-block;
  padding: 0 0.35em;
  border-radius: 0.3em;
  background: #4a3f1c;
}

.kids .text .title {
  margin-top: calc(3cqw * var(--fit, 1));
  color: #8cc4ee;
  font-family: "Nunito", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: calc(6.4cqw * var(--fit, 1));
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.kids .text .subtitle {
  margin-top: calc(3.5cqw * var(--fit, 1));
  color: #9fb4c8;
  font-size: calc(3cqw * var(--fit, 1));
  text-align: center;
}

.kids .text .author {
  margin-top: calc(4cqw * var(--fit, 1));
  font-size: calc(3.3cqw * var(--fit, 1));
  text-align: center;
}

.kids .text .end {
  margin-top: 0.6em;
  color: #8cc4ee;
  font-size: calc(7cqw * var(--fit, 1));
  line-height: 1.3;
  text-align: center;
}

nav > .lang {
  position: relative;
  box-sizing: border-box;
  min-width: 44px;
  padding: 10px 12px;
  border: 1px solid #333;
  border-radius: 10px;
  background: #111;
  color: #eee;
  text-align: center;
  white-space: nowrap;
}

nav > .lang:hover, nav > .lang:focus-within {
  border-color: #666;
}

nav > .lang select {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.kids nav > span.count {
  min-width: 2.5em;
}

@media (max-width: 440px) {
  .kids nav {
    gap: 4px;
  }

  .kids nav .w, .kids nav > a[rel=first] {
    display: none;
  }
}
